1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
--TEST--
pecl/http-v2 - partial clean
--SKIPIF--
<?php
if (!extension_loaded("http")) {
die("skip pecl/http needed");
}
if (!class_exists("http\\Client", false)) {
die("skip pecl/http-v2 with curl support needed");
}
?>
--FILE--
<?php
echo "Test\n";
$h = (array) raphf\stat_persistent_handles();
var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
$c = new http\Client("curl", "PHP");
$c2 = new http\Client("curl", "PHP");
do {
$c->enqueue(new http\Client\Request("GET", "http://php.net"));
$c2->enqueue(new http\Client\Request("GET", "http://php.net"));
} while (count($c) < 3);
$h = (array) raphf\stat_persistent_handles();
var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
unset($c);
$h = (array) raphf\stat_persistent_handles();
var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
raphf\clean_persistent_handles();
$h = (array) raphf\stat_persistent_handles();
var_dump(array_intersect_key($h, array_flip(preg_grep("/^http/", array_keys($h)))));
?>
Done
--EXPECTF--
Test
array(2) {
["http\Client\Curl"]=>
array(0) {
}
["http\Client\Curl\Request"]=>
array(0) {
}
}
array(2) {
["http\Client\Curl"]=>
array(1) {
["PHP"]=>
array(2) {
["used"]=>
int(2)
["free"]=>
int(0)
}
}
["http\Client\Curl\Request"]=>
array(1) {
["PHP:php.net:80"]=>
array(2) {
["used"]=>
int(6)
["free"]=>
int(0)
}
}
}
array(2) {
["http\Client\Curl"]=>
array(1) {
["PHP"]=>
array(2) {
["used"]=>
int(1)
["free"]=>
int(1)
}
}
["http\Client\Curl\Request"]=>
array(1) {
["PHP:php.net:80"]=>
array(2) {
["used"]=>
int(3)
["free"]=>
int(3)
}
}
}
array(2) {
["http\Client\Curl"]=>
array(1) {
["PHP"]=>
array(2) {
["used"]=>
int(1)
["free"]=>
int(0)
}
}
["http\Client\Curl\Request"]=>
array(1) {
["PHP:php.net:80"]=>
array(2) {
["used"]=>
int(3)
["free"]=>
int(0)
}
}
}
Done
|