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