- changelog
[m6w6/ext-http] / tests / HttpRequestPool_002.phpt
1 --TEST--
2 extending HttpRequestPool
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkcls('HttpRequestPool');
7 checkurl('www.php.net');
8 ?>
9 --FILE--
10 <?php
11 echo "-TEST\n";
12
13 class MyPool extends HttpRequestPool
14 {
15 public function send()
16 {
17 while ($this->socketPerform()) {
18 if (!$this->socketSelect()) {
19 throw new HttpSocketException;
20 }
21 }
22 }
23
24 protected final function socketPerform()
25 {
26 $result = parent::socketPerform();
27
28 echo ".";
29 foreach ($this->getFinishedRequests() as $r) {
30 echo "=", $r->getResponseCode(), "=";
31 $this->detach($r);
32 }
33
34 return $result;
35 }
36 }
37
38 $pool = new MyPool(
39 new HttpRequest('http://www.php.net/', HTTP_METH_HEAD),
40 new HttpRequest('http://www.php.net/', HTTP_METH_HEAD),
41 new HttpRequest('http://www.php.net/', HTTP_METH_HEAD)
42 );
43
44 $pool->send();
45
46 echo "\nDone\n";
47 ?>
48 --EXPECTREGEX--
49 .+TEST
50 \.*=200=\.*=200=\.*=200=
51 Done