Bug #68566 [Com]: Operation timeouts contain misleading error description
Edit report at https://bugs.php.net/bug.php?id=68566&edit=1
ID: 68566
Comment by: joe dot afflerbach+phpnet at sevenval dot com
Reported by: marcus at synchromedia dot co dot uk
Summary: Operation timeouts contain misleading error
description
Status: Re-Opened
Type: Bug
Package: HTTP related
PHP Version: 5.6.3
Block user comment: N
Private report: N
New Comment:
Works for me with PHP 7.0.6 and pecl HTTP 3.0.1 linked against curl 7.42.1.
Previous Comments:
------------------------------------------------------------------------
[2014-12-09 21:43:41] mike@php.net
Oh well, should have read the reproducer.
------------------------------------------------------------------------
[2014-12-09 17:15:22] mike@php.net
Actually, both of this fields are filled by libcurl.
"Could not resolve host" would be thrown for a DNS lookup *failure*, but you actually
timed out *while* resolving the host name.
------------------------------------------------------------------------
[2014-12-08 12:10:41] marcus at synchromedia dot co dot uk
Note that this resport is against pecl_http 2.1.4, not the old 1.x version covered by PHP docs.
------------------------------------------------------------------------
[2014-12-08 12:08:01] marcus at synchromedia dot co dot uk
Description:
------------
Just a little thing! If you request a URL that takes longer than the allowed time to respond (as set
in client options), the response correctly sets a CURL error code of 28
(http://curl.haxx.se/libcurl/c/libcurl-errors.html; CURLE_OPERATION_TIMEDOUT), but the text of the
error is "Resolving timed out after <x> milliseconds". This is misleading because
it's not the resolving that is timing out, but the request.
I suppose you could argue that you can apply the term 'resolving' to the fetching of a
URL, but it would be unusual as that term is usually reserved for DNS lookups.
For a DNS resolution error, the curlerror would be 6 - an example error for that is:
6: Could not resolve host: <host name>
Test script:
---------------
Test target:
<?php
sleep(5);
echo 'ok';
Test script:
<?php
$request = new http\Client\Request("GET",
"http://localhost/slow.php"
);
$request->setOptions(["timeout" => 1]);
$client = new http\Client;
try {
$client->enqueue($request)->send();
} catch (Exception $e) {
$response = $client->getResponse();
$t = $response->getTransferInfo();
echo $t->curlcode . ': ' . $t->error;
}
Expected result:
----------------
28: Operation timed out after 1000 milliseconds
Actual result:
--------------
28: Resolving timed out after 1000 milliseconds
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68566&edit=1
Thread (6 messages)