这个说法正确吗?HTTP GET 方法总是没有消息体 [英] Is this statement correct? HTTP GET method always has no message body

查看:24
本文介绍了这个说法正确吗?HTTP GET 方法总是没有消息体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个说法正确吗?HTTP GET 方法总是没有消息体.我没有找到 RFC2616 的任何部分明确说明这一点.

Is this statement correct? HTTP GET method always has no message body. I didn't find any part of RFC2616 explicitly say this.

如果不是这样,那么在什么情况下 Http GET 请求会包含消息体

And if this is not true, then in what circumstances will an Http GET request include a message body

推荐答案

restclientREST 控制台 支持这个,但是 curl 支持.

Neither restclient nor REST console support this but curl does.

原始 HTTP 1.1 规范在章节中说4.3

如果请求方法的规范(第 5.1.1 节)不允许在请求中发送实体主体,则消息主体不得包含在请求中.

A message-body MUST NOT be included in a request if the specification of the request method (section 5.1.1) does not allow sending an entity-body in requests.

第 5.1.1 节 将我们重定向到节9.x 用于各种方法.它们都没有明确禁止包含消息体.不过……

Section 5.1.1 redirects us to section 9.x for the various methods. None of them explicitly prohibit the inclusion of a message body. However...

第 5.2 节

Internet 请求所标识的确切资源是通过检查 Request-URI 和 Host 标头字段来确定的.

The exact resource identified by an Internet request is determined by examining both the Request-URI and the Host header field.

第 9.3 节

GET 方法意味着检索由 Request-URI 标识的任何信息(以实体的形式).

The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.

这表明在处理 GET 请求时,服务器不需要检查 Request-URI 和 Host 标头字段以外的任何内容.

Which together suggest that when processing a GET request, a server is not required to examine anything other that the Request-URI and Host header field.

总之,HTTP 规范并没有阻止您使用 GET 发送消息体,但是如果不是所有服务器都支持它,我不会感到惊讶.

In summary, the HTTP spec doesn't prevent you from sending a message-body with GET, but there is sufficient ambiguity that it wouldn't surprise me if it was not supported by all servers.

这篇关于这个说法正确吗?HTTP GET 方法总是没有消息体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆