- update
[m6w6/ext-http] / tests / HttpRequestPool_001.phpt
1 --TEST--
2 HttpRequestPool
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 (5 > (int) PHP_VERSION) and die('skip PHP5 is required for Http classes');
7 ?>
8 --FILE--
9 <?php
10 $urls = array(
11 'http://www.php.net',
12 'http://pear.php.net',
13 'http://pecl.php.net'
14 );
15 $pool = new HttpRequestPool;
16 foreach ($urls as $url) {
17 $pool->attach($reqs[] = new HttpRequest($url, HTTP_HEAD));
18 }
19 $pool->send();
20 foreach ($reqs as $req) {
21 echo $req->getResponseInfo('effective_url'), '=',
22 $req->getResponseCode(), ':',
23 $req->getResponseMessage()->getResponseCode(), "\n";
24 $pool->detach($req);
25 $pool->attach($req);
26 }
27 try {
28 $pool->send();
29 } catch (HttpException $ex) {
30 echo "Catched\n";
31 }
32 $pool->reset();
33 echo "Done\n";
34 ?>
35 --EXPECTF--
36 Content-type: text/html
37 X-Powered-By: PHP/%s
38
39 http://www.php.net/=200:200
40 http://pear.php.net/=200:200
41 http://pecl.php.net/=200:200
42 Catched
43 Done