使用 GET 请求发送 POST 数据是否有效?

发布于 2024-08-18 13:21:19 字数 120 浏览 3 评论 0原文

例如,使用 Curl,我可以在 GET 请求中“发布”数据(发送实体主体)。这是有效的做法吗?我的意思是:

  • 任何 RFC 规范都没有禁止它吗?
  • 有人有充分理由使用它吗?

Using Curl for example, I can "post" data (send an entity-body) in a GET request. Is this a valid thing to do? With that I mean:

  • Is it not forbidden by any RFC specification?
  • Does someone out there use it with good reason?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

娇俏 2024-08-25 13:21:19

请参阅 RFC2616 - 超文本传输​​协议 - HTTP/1.1,第 4.3 节“消息正文”:

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

在第 9.3 节中,不禁止包含实体主体的“GET”。

所以,是的,您可以通过 HTTP GET 请求发送实体主体。

See RFC2616 - Hypertext Transfer Protocol -- HTTP/1.1, section 4.3 "Message Body":

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.

In section 9.3 "GET" including an entity-body is not forbidden.

So, yes, you are allowed to send an entity-body with a HTTP GET request.

仙女山的月亮 2024-08-25 13:21:19

有一个“充分理由”的用例。

elasticsearch 在 GET 请求中使用实体主体数据来尝试使用 GET 动词作为读取,同时还允许比单独的 url 允许的更复杂的规范(很容易)。

There is a "good reason" use case out there.

elasticsearch uses entity-body data in GET requests to try to use the GET verb as a read while also allowing a more complicated specification than url alone allows (easily).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文