Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multi-line HTTP Headers Confusion

In HTTP headers can be multi-line.

For example:

Word-Of-The-Day: The Fox Jumps Over
        the brown dog.

However, when reading the standard, I came to the conclusion that leading and trailing whitespace MAY be removed, so we get "The Fox Jumps Overthe brown dog." Overthe becomes one word when really it should've been "Over the" (two words, seperated by whitespace).

How do I handle parsing of HTTP values in situations like this, i.e. how do I concatenate HTTP-multiline headers to mean the same thing as single line headers?

like image 665
unixman83 Avatar asked Dec 24 '11 22:12

unixman83


1 Answers

The whitespace before the is neither leading nor trailing.

Section 4.2 of the standard defines leading/trailing whitespace as "linear white space occurring before the first non-whitespace character of the field-value or after the last non-whitespace character of the field-value". This space is neither before the first character of the field value nor after the last one.

The rule for this kind of linear white space, inside the field value, is that it "MAY be replaced with a single [space] before interpreting the field value or forwarding the message downstream."

So we get "The Fox Jumps Over the brown dog."

like image 185
David Schwartz Avatar answered Nov 24 '22 05:11

David Schwartz