[wp-trac] [WordPress Trac] #39043: HTTP API :: Its Not Possible To Send Data In Body For GET Requests

WordPress Trac noreply at wordpress.org
Mon Dec 5 01:09:06 UTC 2016


#39043: HTTP API :: Its Not Possible To Send Data In Body For GET Requests
-----------------------------------+-----------------------
 Reporter:  lots.0.logs            |       Owner:
     Type:  enhancement            |      Status:  reopened
 Priority:  normal                 |   Milestone:
Component:  HTTP API               |     Version:  trunk
 Severity:  normal                 |  Resolution:
 Keywords:  has-patch 2nd-opinion  |     Focuses:
-----------------------------------+-----------------------

Comment (by rmccue):

 Per [https://tools.ietf.org/html/rfc7231#section-4.3.1 RFC 7231], "A
 payload within a GET request message has no defined semantics". Handling
 something with undefined semantics is basically impossible. The reason for
 this is that until the newest RFCs (723x, aka httpbis), the body wasn't
 allowed at all ([https://tools.ietf.org/html/rfc2616#section-4.3 RFC 2616,
 4.3]):

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

 Both Requests and WP_HTTP were designed for HTTP 1.1 as published in RFC
 2616, not the newer 723x. Since there's no defined semantics for GET with
 a payload, supporting it is tough: would we build data arrays into a body
 or query strings? Should we send a content-type header? Content-length?
 etc. Requests doesn't allow it so much as it doesn't disallow it.

 The thing here that I think is more relevant is that you can't control the
 query parameters separately to the body parameters, and the choice is made
 for you. Requests specifically includes the `data_format` option to allow
 overriding this. This option was originally added for the reverse case
 (setting `$data` to build a query), but is also useful here.

 The main reason I didn't do this is because the parameter is specifically
 called `body`, which makes me think it should never be a query string. In
 hindsight, I think that was wrong, since `body` is actually used for both.

 tl;dr we should probably support `data_format`

 @dd32 Agree?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39043#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list