php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69313 http\Client doesn't send GET body
Submitted: 2015-03-27 00:55 UTC Modified: 2015-03-27 07:40 UTC
From: php at qzxj dot net Assigned: mike (profile)
Status: Closed Package: pecl_http (PECL)
PHP Version: 5.6.7 OS: Ubuntu 14.10 64-bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
36 - 22 = ?
Subscribe to this entry?

 
 [2015-03-27 00:55 UTC] php at qzxj dot net
Description:
------------
pecl_http doesn't work properly when sending a GET request with a body. The server hangs for about 10 seconds once send() is called. It looks like the Content-Length is getting sent but the request body is not, so apache is hanging waiting for the body to be sent but it never comes.

Curl command line works:

    $ curl -X GET localhost/test.php -d 'hello'
    GET application/x-www-form-urlencoded, 3 bytes: foo

But my demo script doesn't:

    $ php demo.php
    GET text/plain, 3 bytes:


Test script:
---------------
<?php
// http://localhost/test.php
echo "{$_SERVER['REQUEST_METHOD']} ".
     "{$_SERVER['CONTENT_TYPE']}, {$_SERVER['CONTENT_LENGTH']} bytes: ".
     file_get_contents('php://input')."\n";

// demo.php
$c = new \http\Client;
$r = new \http\Request(
    'GET', 'http://localhost/test.php',
    ['Content-Type'=>'text/plain'],
    (new \http\Message\Body)->append('foo')
);
$s = microtime(true);
$rs = $c->enqueue($r)->send()->getResponse();
$t = microtime(true) - $s;
echo "Took $t seconds\n";
echo $rs->getBody()."";



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-27 07:40 UTC] mike@php.net
-Status: Open +Status: Verified -Assigned To: +Assigned To: mike
 [2015-03-27 09:16 UTC] mike@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=pecl/http/pecl_http.git;a=commit;h=f95804b9731a37187624208a1e2f720da373a989
Log: Fixed bug #69313
 [2015-03-27 09:16 UTC] mike@php.net
-Status: Verified +Status: Closed
 [2015-03-27 09:18 UTC] php at qzxj dot net
Amazing! Thanks for the super-fast turnaround!
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Nov 27 19:03:46 2022 UTC