|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-05-02 10:49 UTC] francois dot pasini at gmail dot com
Description: ------------ I'am using the http extension (2.0.6). If ONE http\Exception\RuntimeException occurs during a call with multiple http\Client::send ALL queries do not call the callback. If the request on error does not call the callback that can understand this, but ALL the others do not call their own callback, then I think it's a bug. Test script: --------------- $urls = ['http://www.google.fr', 'http://www.google.com', 'http://www.notexist.think', 'http://yahoo.com']; $httpClient = new \http\client(); foreach ($urls as $url) { $httpRequest = new \http\Client\Request('GET', $url); $httpRequest->setOptions(['redirect' => 10, 'postredir' => \http\Client\Curl\POSTREDIR_ALL]); $httpClient->enqueue($httpRequest, function($r){var_dump('callback '.$r->getTransferInfo('effective_url'));return true;}); } try { $httpClient->send(); } catch (\Exception $e) { var_dump($e->getMessage()); } Expected result: ---------------- string(30) "callback http://www.google.fr/" string(31) "callback http://www.google.com/" string(35) "callback https://fr.yahoo.com/?p=us" string(42) "Could not resolve host: www.notexist.think" OR string(30) "callback http://www.google.fr/" string(31) "callback http://www.google.com/" string(35) "callback https://fr.yahoo.com/?p=us" string(9) "callback " string(42) "Could not resolve host: www.notexist.think" Actual result: -------------- string(42) "Could not resolve host: www.notexist.think" PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 03:00:01 2025 UTC |
Thank you for your report, but this is not a bug. Please use the more specific API for this sophisticated use case: while ($httpClient->once()) { $httpClient->wait(); } This will generate a warning instead of an exception and you're able to inspect the error in the callback ($r->getTransferInfo("error"))