如果 GET 请求中未指定 http 版本,为什么服务器不等待 http headers?
Why do servers not wait for http headers if the http version is not specified in a GET request?
如果我在没有指定 http 版本的情况下通过 netcat 发出 GET 请求 - GET /
,我会收到服务器的响应,而无需等待我先发送任何 headers 和一个空行.但是,如果版本存在 - GET / HTTP/0.1
,它会正常运行,即使它是 0.1
。我在 google.com
、apache.org
和 microsoft.com
上测试了它。它是由协议定义的吗?
这种请求形式(GET /
没有版本号)被 HTTP 协议的早期版本 HTTP/0.9 使用,它不支持 headers全部。参见 The Original HTTP as defined in 1991。
后来的 HTTP 1.0 规范(RFC 1945) and HTTP 1.1 (RFC 2616) require HTTP 1.0+ implementations to recognize HTTP 0.9 requests and responses (RFC 7230 HTTP 1.1 后来放弃了该要求)。
RFC 1945 规定:
The version of an HTTP message is indicated by an HTTP-Version field in the first line of the message. If the protocol version is not specified, the recipient must assume that the message is in the simple HTTP/0.9 format.
如果我在没有指定 http 版本的情况下通过 netcat 发出 GET 请求 - GET /
,我会收到服务器的响应,而无需等待我先发送任何 headers 和一个空行.但是,如果版本存在 - GET / HTTP/0.1
,它会正常运行,即使它是 0.1
。我在 google.com
、apache.org
和 microsoft.com
上测试了它。它是由协议定义的吗?
这种请求形式(GET /
没有版本号)被 HTTP 协议的早期版本 HTTP/0.9 使用,它不支持 headers全部。参见 The Original HTTP as defined in 1991。
后来的 HTTP 1.0 规范(RFC 1945) and HTTP 1.1 (RFC 2616) require HTTP 1.0+ implementations to recognize HTTP 0.9 requests and responses (RFC 7230 HTTP 1.1 后来放弃了该要求)。
RFC 1945 规定:
The version of an HTTP message is indicated by an HTTP-Version field in the first line of the message. If the protocol version is not specified, the recipient must assume that the message is in the simple HTTP/0.9 format.