httpwg / http-core

Core HTTP Specifications
https://httpwg.org/http-core/
467 stars 43 forks source link

If-Range distinguishing entity-tag from HTTP-date can be more refined #1103

Open amichair opened 1 year ago

amichair commented 1 year ago

RFC9110 section 13.1.5 states:

A valid entity-tag can be distinguished from a valid HTTP-date by examining the first three characters for a DQUOTE.

To my understanding this is because an etag must start with either " or W/", but if so, this means the phrasing can be more precise:

A valid entity-tag can be distinguished from a valid HTTP-date by examining the first and third characters for a DQUOTE.

This also better clarifies why it works (otherwise the reader may infer that checking the second character is also needed, causing her to question her understanding of the syntax) and makes for more efficient implementations (micro-optimized, but still). In any case an implementation is free to check all three characters, or the whole string, or any other way it likes. Actually, wouldn't it also be enough to only check the last character for a DQUOTE?

amichair commented 1 year ago

Further, since the client MUST NOT generate an If-Range header field containing an entity tag that is marked as weak, isn't it sufficient to only check the first character for a DQUOTE?