Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ETag vs. date in If-Range HTTP header

According to RFC7233, an If-Range HTTP header can either be an entity-tag or an HTTP-date. In this context, section 3.2 of the RFC states

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

My question: Why do we need two characters? Since weak entity-tags are not allowed here, I would have thought that testing whether the first character is a DQUOTE is enough.

like image 547
jochen Avatar asked May 29 '26 10:05

jochen


1 Answers

The answer would appear to be you do not need to examine two characters, looking at the first character only is sufficient for implementing If-Range.

If you look at Apache HTTP Server implementation you can see that it only examines the first character (http_protocol.c, line 477 at time of writing).

if (if_range[0] == '"') {

I think the slightly misleading wording of the text can be explained by looking at an earlier version of the HTTP 1.1 specification (RFC2616) where it says:

The server can distinguish between a valid HTTP-date and any form of entity-tag by examining no more than two characters.

The older statement is not wrong but not immediately relevant to If-Range where only strong ETags are permissible.

I expect the RFC7233 form of the text was an attempt to make the previous text clearer but unfortunately on this occasion it didn't achieve the clarity it sought.

like image 103
Mark McLaren Avatar answered Jun 02 '26 21:06

Mark McLaren



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!