Hi Farrukh,
Unlike other HTTP headers, the syntax for an entity tag is a quoted-string [1] or * (unquoted). Given that the header() method is generic, you must specify the value in the correct syntax --within quotes in this case. EntityTag.toString() should return a quoted string.
-- Santiago
[1]
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.24
On Nov 17, 2011, at 4:53 PM, Farrukh Najmi wrote:
>
> Hi Guys,
>
> I am playing with HTTP Conditional GET support in jersey (nice!) and came across something that seems unexpected.
> If the "If-None-Match" is provided unquoted then I get an error:
>
> 2 > GET http://localhost:9090/xyz
> 2 > if-none-match: -142345b90ecd5fe655e4a4acdaf3db5b9ebaf827
> 2 > accept: ...
> 2 > user-agent: Java/1.6.0_20
> 2 > host: localhost:9090
> 2 > connection: keep-alive
> 2 >
>
> Nov 17, 2011 4:46:56 PM com.sun.jersey.api.container.filter.LoggingFilter$Adapter finish
> INFO: 2 * Server out-bound response
> 2 < 400
> 2 < Content-Type: text/plain
> 2 <
> Bad If-None-Match header value: '-142345b90ecd5fe655e4a4acdaf3db5b9ebaf827'
>
> If the header value is quoted all is well:
>
> - resp = webResource.header("If-None-Match", etag.getValue()).get(ClientResponse.class);
> + resp = webResource.header("If-None-Match", "\"" + etag.getValue() + "\"").get(ClientResponse.class);
>
> In the debugger I saw that there is a ParseException while parsing the etag value.
>
> Is this a bug?
>
> --
> Regards,
> Farrukh Najmi
>
> Web: http://www.wellfleetsoftware.com
>
>