Multiline HTTP Confusion Headers

HTTP headers can be multi-line.

For instance:

Word-of-the-day: Fox jumps through
brown dog

However, after reading the standard, I came to the conclusion that leading and trailing spaces MAY be removed , so we get "The Fox Jumps Oververthe brown dog". Coagulation becomes one word when it really should be β€œabove” (two words separated by spaces).

How to handle the parsing of HTTP values ​​in such situations, for example, how can I combine HTTP multi-line headers to mean the same thing as single-line headers?

+6
source share
1 answer

The spaces before the are neither leading nor trailing.

Section 4.2 of the standard defines a leading / trailing white space as "linear white space that occurs before the first non-white character of a field value or after the last non-white character of a field value". This space should not be before the first character of the field value or after the last.

The rule of such a linear space inside a field value is that it "MAY be replaced with one [space] before interpreting the field value or forwarding the message downstream."

So we get Fox Jumping Over the Brown Dog.

+12
source

Source: https://habr.com/ru/post/904443/


All Articles