note 101421 added to class.httprequestpool

From: Date: Wed, 15 Dec 2010 19:09:41 +0000
Subject: note 101421 added to class.httprequestpool
Groups: php.notes 
Request: Send a blank email to php-notes+get-174962@lists.php.net to get a copy of this message
Here's a better example of using HttpRequestPool than the one attached to the __construct page. I wanted to make it clearer what happens when a request fails, plus I find that http_parse_headers produces more readily usable results than HttpRequest::getResponseHeader() and friends. <?php $requests = array( 'http://www.examplexxxyyyzzz.com/', 'http://www.google.com/', 'http://www.php.net/' ); $pool = new HttpRequestPool; $options = array( 'timeout' => 5, 'connecttimeout' => 5, 'ssl' => array('verifypeer' => false, 'verifyhost' => false) ); foreach ($requests as $url) { $pool->attach(new HttpRequest($url, HttpRequest::METH_HEAD, $options)); } try { $pool->send(); } catch (HttpException $e) { echo $e; } foreach($pool as $request) { $out[] = http_parse_headers($request->getRawResponseMessage()); } var_dump($out); ?> ---- Server IP: 89.31.146.176 Probable Submitter: 77.204.145.88 ---- Manual Page -- http://www.php.net/manual/en/class.httprequestpool.php Edit -- https://master.php.net/note/edit/101421 Del: integrated -- https://master.php.net/note/delete/101421/integrated Del: useless -- https://master.php.net/note/delete/101421/useless Del: bad code -- https://master.php.net/note/delete/101421/bad+code Del: spam -- https://master.php.net/note/delete/101421/spam Del: non-english -- https://master.php.net/note/delete/101421/non-english Del: in docs -- https://master.php.net/note/delete/101421/in+docs Del: other reasons-- https://master.php.net/note/delete/101421 Reject -- https://master.php.net/note/reject/101421 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#174962) next »