3

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.

Community
  • 1
  • 1
jochen
  • 3,728
  • 2
  • 39
  • 49

1 Answers1

2

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.

Community
  • 1
  • 1
Mark McLaren
  • 11,470
  • 2
  • 48
  • 79