2

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.

1 Answer 1

5

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.