php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69357 HTTP/1.1 100 Continue overriding subsequent 200 response code with PUT request
Submitted: 2015-04-02 13:51 UTC Modified: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: php at qzxj dot net Assigned:
Status: Closed Package: pecl_http (PECL)
PHP Version: 5.6.7 OS:
Private report: No CVE-ID: None
 [2015-04-02 13:51 UTC] php at qzxj dot net
Description:
------------
We have observed some new and unexpected behaviour with PUT requests since upgrading from 2.2 to 2.4.1. A PUT request which triggers a HTTP/1.1 100 Continue followed by a 200 OK returns 100 when getResponseCode() is called.

I have supplied a fairly terrible server script below that returns exactly the same response structure as the server we're interacting with which is causing the problem for us.

The request headers I see using both 2.2 and 2.4.1 are the same (apart from the version number in the UA, of course):

PUT / HTTP/1.1
User-Agent: PECL_HTTP/2.4.1 PHP/5.6.7 libcurl/7.37.1
Host: localhost:8081
Accept: */*
Content-Length: 3
Expect: 100-continue

Using 2.2, the client script below shows a response code of 200. Using 2.4.1, it shows 100.

Test script:
---------------
if ($argv[1] == 'server') {
    $s = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    socket_set_option($s, SOL_SOCKET, SO_REUSEADDR, 1);
    socket_bind($s, "127.0.0.1", 8081);
    socket_listen($s);
    while (true) {
        $c = socket_accept($s);
        $h = socket_read($c, 8192);
        echo $h;
        socket_write($c, "HTTP/1.1 100 Continue\r\n\r\n");
        socket_write($c, implode("\r\n", [
            "HTTP/1.1 200 OK",
            "Content-Length: 3",
            "Content-Type: text/plain",
            "",
            "foo",
            "",
        ])."\r\n");
        socket_close($c);
    }
    socket_close($s);
}
elseif ($argv[1] == 'client') {
    $rq = new \Http\Client\Request('PUT', 'http://localhost:8081/', [], 
        (new \Http\Message\Body)->append("foo")
    );
    $c = new \Http\Client;
    $rs = $c->enqueue($rq)->send()->getResponse();
    var_dump($rs->getResponseCode());
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-04-08 10:06 UTC] mike@php.net
Automatic comment on behalf of mike
Revision: http://git.php.net/?p=pecl/http/pecl_http.git;a=commit;h=8c2a81a3728b23332ecb33a5f72727ea121dbeeb
Log: fix bug #69357
 [2015-04-08 10:06 UTC] mike@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 05:01:28 2024 UTC