Hi Jon,
See the source for:
com.sun.jersey.spi.container.ContainerRequest
When calling evaluatePreconditions(etag) the following occurs:
1) If a If-Match is present then that will be processed; otherwise;
2) If a If-None-Match is present then that will be processed; otherwise;
3) null is returned.
Do you want behavior such that if If-Match or If-None-Match is not
represent a 400 response should be returned?
Paul.
On Jan 11, 2011, at 3:32 PM, Jonathan Cook - FM&T wrote:
> Hello,
>
> I am exploring the use of Etags and was a little bit confused, does
> the evaluatePreconditions handle checking to see if the If-None-
> Match header exists or is it down to resource to determine this. For
> example I have the following piece of code:
>
> @GET
> @Path("competition/{comp}")
> @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> public Response getTable(@Context Request request,
> @PathParam("comp") final String comp) throws WebApplicationException {
> String result =
> executeXQuery(String.format(FIND_TABLE_BY_COMP_XQUERY, comp),
> CACHE_KEY_PREFIX+comp);
>
> CacheControl cacheControl = new CacheControl();
> cacheControl.setMaxAge(cacheControlMaxAge);
>
> EntityTag etag = computeEntityTag(result);
> Response.ResponseBuilder responseBuilder =
> request.evaluatePreconditions(etag);
> if (responseBuilder != null) {
> LOG.debug("Table has not changed..returning unmodified
> response code");
> return
> responseBuilder.cacheControl(cacheControl).build();
> }
>
> return
> Response.ok(result).cacheControl(cacheControl).tag(etag).build();
> }
>
> But it doesn’t appear to take into account whether If-None-Match is
> in the request header or not. I can’t actually find the source for
> evaluatePreconditions.
>
> Thanks
> Jon