Terin Stock created COUCHDB-2940:
------------------------------------

             Summary: ETag If-None-Match comparison must be weak
                 Key: COUCHDB-2940
                 URL: https://issues.apache.org/jira/browse/COUCHDB-2940
             Project: CouchDB
          Issue Type: Bug
            Reporter: Terin Stock


When a request is received with a {{If-None-Match}} header, the ETag comparison 
must be weak, according to [RFC7232 § 
3.2|https://tools.ietf.org/html/rfc7232#section-3.2]: (emphasis original)

bq. A recipient MUST use the weak comparison function when comparing 
entity-tags for If-None-Match (Section 2.3.2), since weak entity-tags can be 
used for cache validation even if there have been changes to the representation 
data.

Earlier [§ 2.3.2|https://tools.ietf.org/html/rfc7232#section-2.3.2] gives a 
helpful table for the differences between strong and weak validation:

bq. {noformat}
The example below shows the results for a set of entity-tag pairs and
both the weak and strong comparison function results:

+--------+--------+-------------------+-----------------+
| ETag 1 | ETag 2 | Strong Comparison | Weak Comparison |
+--------+--------+-------------------+-----------------+
| W/"1"  | W/"1"  | no match          | match           |
| W/"1"  | W/"2"  | no match          | no match        |
| W/"1"  | "1"    | no match          | match           |
| "1"    | "1"    | match             | match           |
+--------+--------+-------------------+-----------------+
{noformat}

CouchDB currently uses strong comparison, even for {{If-None-Match}}.

{noformat}
$ curl -vo /dev/null http://couchdb.local/db/document1 
-H'If-None-Match:"8FTYH1N3L0TPD7ZEZCPW16J4T"'

[…snip…]

< HTTP/1.1 304 Not Modified
< Server: CouchDB/1.6.1 (Erlang OTP/18)
< ETag: "8FTYH1N3L0TPD7ZEZCPW16J4T"
< Date: Tue, 26 Jan 2016 19:47:46 GMT
< Content-Length: 0

$ curl -vo /dev/null http://couchdb.local/db/document1 
-H'If-None-Match:W/"8FTYH1N3L0TPD7ZEZCPW16J4T"'

[…snip…]

< HTTP/1.1 200 OK
< Vary: Accept
< Server: CouchDB/1.6.1 (Erlang OTP/18)
< Etag: "8FTYH1N3L0TPD7ZEZCPW16J4T"
< Date: Tue, 26 Jan 2016 19:49:25 GMT
< Content-Type: application/json
< Content-Length: 1449
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to