[wp-trac] [WordPress Trac] #37456: HTTP API regression in transmitted content and headers

WordPress Trac noreply at wordpress.org
Mon Jul 25 10:28:55 UTC 2016


#37456: HTTP API regression in transmitted content and headers
--------------------------+-------------------
 Reporter:  Clorith       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  4.6
Component:  HTTP API      |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-------------------
 The HTTP API changed how it sends data in 4.6, possibly related with the
 move to Requests, as it appears to be the only noticeable change to the
 HTTP API since 4.5?

 The following test call was made on both 4.5 and 4.6
 {{{#!php
 <?php
 wp_remote_post(
         'http://127.0.0.1/http_test.php',
         array(
                 'method'  => 'DELETE',
                 'body'    => array( 'tags' => array( 'example' ) ),
                 'timeout' => 20
         )
 )
 }}}

 `http_test.php` is just a simple capture file that does a `var_dump` on
 `apache_request_headers`, `$_GET` `$_POST` and stream content.

 In 4.5 this transmits the following headers with empty _POST and _GET and
 transmits the data as a stream (capturable with `file_get_contents(
 'php://input' )`):

 {{{
 'User-Agent' => 'WordPress/4.5.3; http://127.0.0.1/wordpress',
 'Host' => '127.0.0.1',
 'Accept' => '*/*',
 'Accept-Encoding' => 'deflate;q=1.0, compress;q=0.5, gzip;q=0.5',
 'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
 'Content-Length' => '19'
 }}}

 The content of the streamed data is a single string as such

 `tags%5B0%5D=example`

 In 4.6 this behavior changed, we are now seeing the following headers,
 with an empty _POST and stream, but a populated _GET value:

 {{{
 'User-Agent' => 'WordPress/4.6-beta4-38147; http://127.0.0.1/wordpress',
 'Host' => '127.0.0.1',
 'Accept' => '*/*',
 'Accept-Encoding' => 'deflate, gzip',
 'Referer' => 'http://127.0.0.1/http_test.php?tags%5B0%5D=example',
 'Connection' => 'close',
 'Content-Length' => '0',
 'Content-Type' => 'application/x-www-form-urlencoded'
 }}}

 And as mentioned the streamed data is empty, but the _GET contains the
 array data:


 {{{
 array (
   'tags' =>
   array (
     0 => 'example',
   ),
 )
 }}}

 As reported by @ze3kr in https://wordpress.org/support/topic/a-bug-of-
 delete-method-of-wp_remote_post-in-v46-beta4

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37456>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list