英文:
Newlines in HTTP
问题
HTTP 1.1标准规定换行符为CRLF。但是wget
、lynx
和firefox
都接受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
> 虽然起始行和字段的行终止符是序列CRLF,但接收方可以将单个LF识别为行终止符,并忽略任何前面的CR。
如果您要构建一个接收方(客户端或服务器),解析仅发送LF作为行终止符的请求将符合RFC标准。
英文:
> 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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论