Reputation: 2342
We use ETag header for syncronization on server and it corresponds to entities 'int version' field in DB. According to w3c docs: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html Examples:
ETag: "xyzzy"
ETag: W/"xyzzy"
ETag: ""
It means that ETag inside double quotes. So if I want to send it to client it should be done like:
int version = 2;
response.setHeader(HttpHeaders.ETAG, String.format("\"%s\"", version));
Or:
int version = 2;
response.setHeader(HttpHeaders.ETAG, String.format("%s", version));
In first case I get:
HTTP/1.1 200 OK
...
ETag: 2
In second:
HTTP/1.1 200 OK
...
ETag: "2"
Which way is more w3c compliant?
Upvotes: 2
Views: 2461
Reputation: 42025
a) the W3C doesn't matter. You are looking at a copy of the IETF RFC 2616, hosted by the W3C. And that RFC is obsoleted, you should read RFC 7232 (for instance http://greenbytes.de/tech/webdav/rfc7232.html#header.etag).
b) Of your examples, the first one is incorrect, and the second one is correct.
Upvotes: 3