php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58300 http_get returns an empty string upon timeout, not false
Submitted: 2008-08-05 08:49 UTC Modified: 2008-12-05 12:00 UTC
From: alangland at andyl56 dot com Assigned: mike (profile)
Status: Not a bug Package: pecl_http (PECL)
PHP Version: 5_3 CVS-2008-08-05 (dev) OS: Windows XP + 2003 Server
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:
46 + 34 = ?
Subscribe to this entry?

 
 [2008-08-05 08:49 UTC] alangland at andyl56 dot com
Description:
------------
http_get is supposed to return false on connection timeout, but instead it returns an empty string.

Library version according to php.exe --re http:


http version 1.6.1-dev

Reproduce code:
---------------
if (false === ($http = http_get('http://0.0.0.0/', array('timeout' =>
15, 'connecttimeout' => 15)))) {
  echo 'FALSE returned';
}
else {
  var_dump($http);
}

Expected result:
----------------
FALSE returned

Actual result:
--------------
string(0) ""

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-05 04:56 UTC] mike@php.net
Thank you for taking the time to write to us, but this is not
a bug.

FALSE is only returned on "hard" failures like parsing parameters or building the request.  As soon as it comes to execute the request the return value will be the response, i.e. on any serious connect/transfer failure an empty string resp. a partially received response.

Thanks.
 [2008-12-05 12:00 UTC] alangland at andyl56 dot com
Thanks for your response. If this is the intended behavior, would you please document this in the official manual so developers are at least aware of it?
 [2010-01-15 18:22 UTC] david dot h at highgearmedia dot com
How then can I detect a timeout? Should I compare total_time to my timeout value? Is this guaranteed to be > on timeout and <= on completion? Do I need to examine the error string?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 11:01:34 2024 UTC