Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax for ETag?

Redbot reports that my webpage has invalid header:

The ETag header's syntax isn't valid.

My headers are set to:

ETag: 4ae413bd 

Why is it invalid?

What is the syntax for an ETag?

like image 327
Pacerier Avatar asked Jul 16 '11 18:07

Pacerier


2 Answers

Try ETag: "4ae413bd". The value of an ETag must follow the ABNF form:

  entity-tag = [ weak ] opaque-tag   weak       = "W/"   opaque-tag = quoted-string    quoted-string  = ( <"> *(qdtext | quoted-pair ) <"> )   qdtext         = <any TEXT except <">>   quoted-pair    = "\" CHAR   CHAR           = <any US-ASCII character (octets 0 - 127)>   TEXT           = <any OCTET except CTLs, but including LWS>   OCTET          = <any 8-bit sequence of data>   LWS            = [CRLF] 1*( SP | HT )   CTL            = <any US-ASCII control character (octets 0 - 31) and DEL (127)>   CRLF           = CR LF   CR             = <US-ASCII CR, carriage return (13)>   LF             = <US-ASCII LF, linefeed (10)>   SP             = <US-ASCII SP, space (32)>   HT             = <US-ASCII HT, horizontal-tab (9)> 

, which is basically ([wW]/)?"([^"]|\\")*" in regular regex.

Note that both "\" and "/" are valid values for etags.

References: section-14.19, section-3.11, section-2.2.

like image 64
Pacerier Avatar answered Sep 30 '22 04:09

Pacerier


As Arnaud mentioned, make sure that you have quoted the value.

replace

new EntityTagHeaderValue("0"); 

with

new EntityTagHeaderValue("\"0\""); 
like image 27
14 revs, 12 users 16% Avatar answered Sep 30 '22 06:09

14 revs, 12 users 16%