962ea0527463a72457416f27c0fb1875edc1a0ec
[m6w6/ext-http] / docs / examples / Parallel_Requests.php
1 <?php
2 try {
3 $p = new HttpRequestPool;
4 // if you want to set _any_ options of the HttpRequest object,
5 // you need to do so *prior attaching* to the request pool!
6 $p->attach(new HttpRequest('http://pear.php.net', HTTP_HEAD));
7 $p->attach(new HttpRequest('http://pecl.php.net', HTTP_HEAD));
8 } catch (HttpException $e) {
9 print $e;
10 exit;
11 }
12
13 try {
14 $p->send();
15 // HttpRequestPool implements an iterator over attached HttpRequest objects
16 foreach ($p as $r) {
17 print "Checking ", $r->getUrl(), " reported ", $r->getResponseCode(), "\n";
18 }
19 } catch (HttpException $e) {
20 print $e;
21 }
22 ?>