Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is considered as whitespace in HTTP header

I've just been reading HTTP standard (propsed standard to be more precise) part 1 and got confused with what they consider as "whitespace" in section 3, second to last paragraph: https://www.rfc-editor.org/rfc/rfc7230#section-3

Since returns (CRLFs) terminate HTTP header, the only whitespaces that may be implied are 0x20 'Space' characters. Wikipedia lists another kinds of whitespace ASCII symbols, like 'Non-breaking space' 0xA0, so I still don't understand this ("whitespace") concept.

Please, help me figure out what it really means in scope of this standard.

like image 408
RedRidingHood Avatar asked Mar 07 '23 06:03

RedRidingHood


1 Answers

RFC 7230, which you linked to, defines EXACTLY what it considers to be whitespace in a header:

HTTP-message   = start-line
                 *( header-field CRLF )
                 CRLF
                 [ message-body ]

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

obs-text       = %x80-FF

OWS            = *( SP / HTAB )
               ; optional whitespace

As you can see, SP (space) and HTAB (horizontal tab) are the only defined whitespace characters. They are defined in RFC 5234 Appendix B.1, which RFC 7230 links to:

HTAB           =  %x09
               ; horizontal tab

SP             =  %x20
like image 125
Remy Lebeau Avatar answered Mar 17 '23 07:03

Remy Lebeau