Newlines in HTTP

huangapple go评论49阅读模式
英文:

Newlines in HTTP

问题

HTTP 1.1标准规定换行符为CRLF。但是wgetlynxfirefox都接受UNIX格式的响应。对于HTTP解析器来说,简单地跳过标题中的所有回车符是否可以接受?

英文:

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?

答案1

得分: 0

是的,这是可以接受的。来自RFC 7230第3.5节“消息解析健壮性”

虽然起始行和标头字段的行终止符是CRLF序列,但接收者可以将单个LF识别为行终止符并忽略任何前导CR。

英文:

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.

答案2

得分: 0

RFC 9112,第2.2节:

> 虽然起始行和字段的行终止符是序列CRLF,但接收方可以将单个LF识别为行终止符,并忽略任何前面的CR。

如果您要构建一个接收方(客户端或服务器),解析仅发送LF作为行终止符的请求将符合RFC标准。

英文:

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.

huangapple
  • 本文由 发表于 2023年5月6日 21:12:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189085.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定