Implementing the If-Match HTTP header in Spring
ShallowEtagHeaderFilter , which is part of Spring, handles the If-None-Match header in the Http request. As part of the Http 1.1 specification, the Http 304 status is returned - unchanged if the content of the If-None-Match header sent on the request matches the Etag header. This is useful for caching as it means that if the Etag is the same on the client and server, then the content will be identical.
This is normal.
However, my question is that Spring supports the If-Match header (part of HTTP 1.1 again) and not If-None-Match, because as the docs go, it looks like ShallowEtagHeaderFilter only handles If-None-Match. I need an If-Match header to prevent concurrent requests from restarting at the same time. IE I want the request to be processed only if the Etags are the same and hence they have the latest version of the object.
source to share
Doesn't seem to ShallowEtagHeaderFilter
support If-Match
:
curl "Accept: application/json" -H 'If-Match: "somevalue"' -i http://localhost:8080/rest-sec/api/resources/1
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
ETag: "03cb37ca667706c68c0aad4cb04c3a211"
Content-Type: application/json;charset=UTF-8
Content-Length: 56
Date: Fri, 11 Jan 2013 14:58:40 GMT
I opened up JIRA to track this: https://jira.springsource.org/browse/SPR-10164
source to share