- add HttpRequestPool::getFinishedRequests(), so now it's possible to process finishe...
[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 $this->handleRequests();
18 if (!$this->socketSelect()) {
19 throw new HttpSocketException;
20 }
21 }
22 $this->handleRequests();
23 }
24
25 private function handleRequests()
26 {
27 echo ".";
28 foreach ($this->getFinishedRequests() as $r) {
29 echo "=", $r->getResponseCode(), "=";
30 $this->detach($r);
31 }
32 }
33 }
34
35 $pool = new MyPool(
36 new HttpRequest('http://www.php.net/', HTTP_METH_HEAD),
37 new HttpRequest('http://at.php.net/', HTTP_METH_HEAD),
38 new HttpRequest('http://de.php.net/', HTTP_METH_HEAD),
39 new HttpRequest('http://ch.php.net/', HTTP_METH_HEAD)
40 );
41
42 $pool->send();
43
44 echo "\nDone\n";
45 ?>
46 --EXPECTREGEX--
47 .+TEST
48 \.+=200=\.+=200=\.+=200=\.+=200=
49 Done