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

Bug #8964 readTimeout isn't working as it should
Submitted: 2006-10-11 11:11 UTC
From: lobbin at gmail dot com Assigned: avb
Status: Closed Package: HTTP_Request2
PHP Version: 5.2.4 OS: Linux/Mac
Roadmaps: 0.2.0    
Subscription  
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
2009-01-04 11:25 UTC
Package:
Bug Type:
Summary:
From: lobbin at gmail dot com
New email:
PHP Version: Package Version: OS:

 

 [2006-10-11 11:11 UTC] lobbin at gmail dot com (Robin Ericsson)
Description: ------------ The problem belongs to a combination of HTTP_Request and Net_Socket. HTTP_Request uses Net_Socket::readLine() to be able to read the HTTP response code. On PHP level this is controlled by stream_set_timeout (which is set with the values of readTimeout, from HTTP_Request) which works as it should. The problem is that Net_Socket wraps the call to fgets in a while loop which uses the "timeout" parameter to check how long the while-loop have been running. Which only leads to while-loop running a few more times until the real "timeout" parameter is done. This is also a Net_Socket bug, but it's triggered by missuse? in HTTP_Request. So maybe HTTP_Request needs to take measures of the correct timeout usage as the user shouldn't care about the underlaying classes.

Comments

 [2008-04-23 12:29 UTC] doconnor (Daniel O'Connor)
I'd need a test script to see this behaviour first hand before I can do anything here...
 [2008-04-23 12:32 UTC] doconnor (Daniel O'Connor)
Unless this is a duplicate of Bug #7691
 [2008-04-23 12:34 UTC] doconnor (Daniel O'Connor)
(and Bug #7692)
 [2008-04-27 06:45 UTC] lobbin at gmail dot com
It was a while since the report, I hardly remembers the problem, but it was something like this. Example page to trigger the problem: <?php sleep( 10 ); echo "Hej\n"; ?> Example script to trigger problem: <?php require_once 'HTTP/Request.php'; $req = new HTTP_Request('http://localhost/test.php', array('timeout' => 20, 'readTimeout' => array(8, 0))); if (!PEAR::isError($req->sendRequest())) { echo $req->getResponseBody(); } ?> Here I would expect the script to return error as the 8 is less than the page time out of 10. However, since we specify timeout (connect timeout) to 20, that sorts of overrides the readTimeout setting. With timeout set to 20, script runs successfully for ~10 secs. With timeout set to less than or equal to readTimeout, script return error after 8 secs.
 [2008-10-17 21:14 UTC] avb (Alexey Borzov)
Moving feature requests to HTTP_Request2.
 [2009-01-04 11:25 UTC] avb (Alexey Borzov)
Impemented in CVS. The request will now throw an exception if it takes more seconds than given 'timeout' parameter.