gpt4 book ai didi

http - HTTP Start-Line 的最大长度

转载 作者:可可西里 更新时间:2023-11-01 17:10:57 24 4
gpt4 key购买 nike

HTTP 是否限制 Start-Line(Request-Line 或 Status-Line)的长度?

如果是,当收到一个 Request-Line 超过最大长度的 HTTP 请求时,HTTP Server 应该响应哪个状态码?

最佳答案

引自 THE HTTP 1.1 RFC(2616) ,

The Request-Line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by SP characters. No CR or LF is allowed except in the final CRLF sequence.

   Request-Line   = Method SP Request-URI SP HTTP-Version CRLF

这里没有指定长度限制。

Request-URI 本身可以很长,rfc 对此也有说明:

The HTTP protocol does not place any a priori limit on the length of a URI. Servers MUST be able to handle the URI of any resource they serve, and SHOULD be able to handle URIs of unbounded length if they provide GET-based forms that could generate such URIs. A server SHOULD return 414 (Request-URI Too Long) status if a URI is longer than the server can handle (see section 10.4.15).

因此 Request-URI 存在“太长”状态,但这意味着“此服务器无法处理太长”而不是“比规范允许的长”。

关于http - HTTP Start-Line 的最大长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15587003/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com