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