fd3853ad0556dbaea5c04d19a5beba3f1dbd59f5
[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 $pool->detach($req);
27 $pool->attach($req);
28 $pool->detach($req);
29 $pool->attach($req);
30 $pool->detach($req);
31 $pool->attach($req);
32 $req->getResponseMessage()->getResponseCode();
33 $req->getResponseMessage()->getResponseCode();
34 $req->getResponseMessage()->getResponseCode();
35 $req->getResponseMessage()->getResponseCode();
36 }
37 $pool->send();
38 $pool->reset();
39 $pool->attach($req);
40 echo "Done\n";
41 ?>
42 --EXPECTF--
43 Content-type: text/html
44 X-Powered-By: PHP/%s
45
46 http://www.php.net/=200:200
47 http://pear.php.net/=200:200
48 http://pecl.php.net/=200:200
49 Done