Newlines in HTTP

42 views Asked by At

The HTTP 1.1 standard says that newlines are CRLF. However wget, lynx, and firefox, all accepts a response in UNIX format.

Is it acceptable for a HTTP parser to simply skip all carriage returns in the header?

2

There are 2 answers

0
Frederik Deweerdt On BEST ANSWER

From RFC 9112, section 2.2:

Although the line terminator for the start-line and fields is the sequence CRLF, a recipient MAY recognize a single LF as a line terminator and ignore any preceding CR.

If you were to build a recipient (client or server), it would be RFC compliant to parse requests that only send an LF as line terminator.

0
Bergi On

Yes, it is acceptable. From ยง3.5. Message Parsing Robustness of RFC 7230:

Although the line terminator for the start-line and header fields is the sequence CRLF, a recipient MAY recognize a single LF as a line terminator and ignore any preceding CR.