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
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:
Package:
Bug Type:
Summary:
From: alangland at andyl56 dot com
New email:
PHP Version: OS:

 

 [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: Tue May 07 11:01:31 2024 UTC