itayb
itayb

Reputation: 149

HTTP empty header

Is it acceptable to have empty header in HTTP? By empty i mean ":" no header name and no header value. The same question is also relvant to HTTP2 (suppose it is the same answer but to be sure).

Thanks.

Upvotes: 2

Views: 1261

Answers (1)

Evert
Evert

Reputation: 99515

HTTP defines a header field as:

     header-field   = field-name ":" OWS field-value OWS

     field-name     = token
     field-value    = *( field-content / obs-fold )
     field-content  = field-vchar [ 1*( SP / HTAB ) field-vchar ]
     field-vchar    = VCHAR / obs-text

     obs-fold       = CRLF 1*( SP / HTAB )
                    ; obsolete line folding
                    ; see Section 3.2.4

The token part is later on defined as:


     token          = 1*tchar

     tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
                    / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
                    / DIGIT / ALPHA
                    ; any VCHAR, except delimiters

The implication is that the header name must be at least 1 byte, and the value can be 0 or more characters.

HTTP/2 uses the same underlying data-model.

https://www.rfc-editor.org/rfc/rfc7230#section-3.2.4

Upvotes: 5

Related Questions