开发者

Is sending POST data with a GET request valid?

开发者 https://www.devze.com 2022-12-17 11:36 出处:网络
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:

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 specifi开发者_Go百科cation?
  • Does someone out there use it with good reason?


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号