Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.6.0

Bug #21108 Requests with body always take 40ms minimum
Submitted: 2016-09-02 09:38 UTC
From: cweiske Assigned:
Status: Bogus Package: HTTP_Request2 (version 2.3.0)
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2016-09-02 09:38 UTC] cweiske (Christian Weiske)
Description: ------------ When sending a HTTP request with a body using the socket adapter, they always take minimum of 40ms. Switching to the curl adapter decreases the time to 2ms. (note that curl in my php 5.5.9 version hangs when using a body with a get request, so I switched to POST there) Test script: --------------- <?php require_once 'HTTP/Request2.php'; $req = new HTTP_Request2('http://127.0.0.1/'); $start = microtime(true); $req->send(); $end = microtime(true); echo 'socket-no--body time: ' . number_format($end - $start, 3) . "s\n"; $req = new HTTP_Request2('http://127.0.0.1/'); $req->setBody('test'); $start = microtime(true); $req->send(); $end = microtime(true); echo 'socket-withbody time: ' . number_format($end - $start, 3) . "s\n"; $req = new HTTP_Request2('http://127.0.0.1/'); $req->setAdapter('curl'); $start = microtime(true); $req->send(); $end = microtime(true); echo 'curl-no--body time: ' . number_format($end - $start, 3) . "s\n"; $req = new HTTP_Request2('http://127.0.0.1/', 'POST'); $req->setAdapter('curl'); $req->setBody('test'); $start = microtime(true); $req->send(); $end = microtime(true); echo 'curl-withbody time: ' . number_format($end - $start, 3) . "s\n"; ?> Expected result: ---------------- socket-withbody time should be 2ms, too. Actual result: -------------- php ~/tmp/httprequest2body.php socket-no--body time: 0.012s socket-withbody time: 0.040s curl-no--body time: 0.003s curl-withbody time: 0.002s

Comments

 [2016-09-02 09:48 UTC] cweiske (Christian Weiske)
If you remove the "socket-nobody" request in the example, the "withbody" request also takes only 2 or 3ms. Adding a "connection: close" header to the "socket-nobody" request also makes the "withbody"-request fast, which points to an issue with re-using the open socket.
 [2020-07-05 19:59 UTC] avb (Alexey Borzov)
-Status: Open +Status: Bogus
Sorry for a long response time. Tried reproducing this with locally installed Apache, nginx and IIS - no luck. I'm 99% sure that the issue was with whatever server was responding at your localhost, especially considering > note that curl in my php 5.5.9 version hangs when using a body with a get request