- Fixed build on php-trunk
[m6w6/ext-http] / tests / HttpRequestPool_006.phpt
1 --TEST--
2 HttpRequestPool detaching in callbacks
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkcls("HttpRequestPool");
7 checkurl("at.php.net");
8 checkurl("de.php.net");
9 ?>
10 --FILE--
11 <?php
12 echo "-TEST\n";
13 class r extends HttpRequest {
14 function onProgress() {
15 static $i = array();
16 if (empty($i[$this->getUrl()])) {
17 $i[$this->getUrl()] = true;
18 try {
19 $GLOBALS['p']->detach($this);
20 } catch (Exception $ex) {
21 echo $ex, "\n";
22 }
23 }
24 }
25 function onFinish() {
26 $GLOBALS['p']->detach($this);
27 }
28 }
29 $p = new HttpRequestPool(new r("http://at.php.net"), new r("http://de.php.net"));
30 $p->send();
31 var_dump($p->getAttachedRequests());
32 echo "Done\n";
33 ?>
34 --EXPECTF--
35 %aTEST
36 exception 'HttpRequestPoolException' with message 'HttpRequest object(#%d) cannot be detached from the HttpRequestPool while executing the progress callback' in %aHttpRequestPool_006.php:%d
37 Stack trace:
38 #0 %aHttpRequestPool_006.php(%d): HttpRequestPool->detach(Object(r))
39 #1 [internal function]: r->onProgress(Array)
40 #2 %aHttpRequestPool_006.php(%d): HttpRequestPool->send()
41 #3 {main}
42 exception 'HttpRequestPoolException' with message 'HttpRequest object(#%d) cannot be detached from the HttpRequestPool while executing the progress callback' in %aHttpRequestPool_006.php:%d
43 Stack trace:
44 #0 %aHttpRequestPool_006.php(%d): HttpRequestPool->detach(Object(r))
45 #1 [internal function]: r->onProgress(Array)
46 #2 %aHttpRequestPool_006.php(%d): HttpRequestPool->send()
47 #3 {main}
48 array(0) {
49 }
50 Done