6efa9cbfaecc71d0c0fe8cb129e929bf6d519bb6
[m6w6/ext-http] / tests / persistent_handles_002.phpt
1 --TEST--
2 persistent handles
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 skipif(!http_support(HTTP_SUPPORT_REQUESTS), "need request support");
7 skipif(function_exists('zend_thread_id'), "need non-ZTS build");
8 ?>
9 --INI--
10 http.persistent.handles.limit=-1
11 http.persistent.handles.ident=GLOBAL
12 --FILE--
13 <?php
14 echo "-TEST\n";
15
16 echo "No free handles!\n";
17 foreach (http_persistent_handles_count() as $provider => $idents) {
18 foreach ((array)$idents as $ident => $counts) {
19 if (!empty($counts["free"])) {
20 printf("%s, %s, %s\n", $provider, $ident, $counts["free"]);
21 }
22 }
23 }
24
25 http_get("http://www.google.com/", null, $info[]);
26
27 echo "One free request handle within GLOBAL: ";
28 var_dump(http_persistent_handles_count()->http_request["GLOBAL"]["free"]);
29
30 echo "Reusing request handle: ";
31 http_get("http://www.google.com/", null, $info[]);
32 var_dump($info[0]["pretransfer_time"] > 10 * $info[1]["pretransfer_time"], $info[0]["pretransfer_time"], $info[1]["pretransfer_time"]);
33
34 echo "Handles' been cleaned up:\n";
35 http_persistent_handles_clean();
36 print_r(http_persistent_handles_count());
37
38 echo "Done\n";
39 ?>
40 --EXPECTF--
41 %sTEST
42 No free handles!
43 One free request handle within GLOBAL: int(1)
44 Reusing request handle: bool(true)
45 float(%f)
46 float(%f)
47 Handles' been cleaned up:
48 stdClass Object
49 (
50 [http_request] => Array
51 (
52 [GLOBAL] => Array
53 (
54 [used] => 0
55 [free] => 0
56 )
57
58 )
59
60 [http_request_datashare] => Array
61 (
62 [GLOBAL] => Array
63 (
64 [used] => 0
65 [free] => 0
66 )
67
68 )
69
70 [http_request_pool] => Array
71 (
72 [GLOBAL] => Array
73 (
74 [used] => 0
75 [free] => 0
76 )
77
78 )
79
80 )
81 Done