- changelog
[m6w6/ext-http] / tests / HttpRequestPool_001.phpt
1 --TEST--
2 HttpRequestPool
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmin(5);
7 checkcls('HttpRequestPool');
8 checkurl('www.php.net');
9 checkurl('dev.iworks.at');
10 ?>
11 --FILE--
12 <?php
13 echo "-TEST\n";
14 $post = new HttpRequest('http://dev.iworks.at/ext-http/.print_request.php', HTTP_METH_POST);
15 $post->addPostFields(array('a'=>1,'b'=>2)) ;
16
17 $pool = new HttpRequestPool(
18 new HttpRequest('http://www.php.net/', HTTP_METH_HEAD),
19 $post
20 );
21
22 $pool->send();
23
24 foreach ($pool as $req) {
25 echo $req->getUrl(), '=',
26 $req->getResponseCode(), ':',
27 $req->getResponseMessage()->getResponseCode(), "\n";
28 }
29
30 foreach ($pool as $req) {
31 try {
32 $pool->attach(new HttpRequest('http://foo.bar'));
33 } catch (HttpRequestPoolException $x) {
34 echo ".\n";
35 }
36 }
37
38 foreach ($pool as $req) {
39 $pool->detach($req);
40 }
41
42 echo "Done\n";
43 ?>
44
45 --EXPECTF--
46 %sTEST
47 http://www.php.net/=200:200
48 http://dev.iworks.at/ext-http/.print_request.php=200:200
49 .
50 .
51 Done