30158358d1eec98faa5b42cea1a1fef8fa75b623
[m6w6/ext-http] / tests / persistent_handles_003.phpt
1 --TEST--
2 persistent handles
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 checkmax(4.4);
7 skipif(!http_support(HTTP_SUPPORT_REQUESTS), "need request support");
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 $h = http_persistent_handles_count();
29 var_dump($h->http_request["GLOBAL"]["free"]);
30
31 echo "Reusing request handle: ";
32 http_get("http://www.google.com/", null, $info[]);
33 var_dump($info[0]["pretransfer_time"] > 10 * $info[1]["pretransfer_time"], $info[0]["pretransfer_time"], $info[1]["pretransfer_time"]);
34
35 echo "Handles' been cleaned up:\n";
36 http_persistent_handles_clean();
37 print_r(http_persistent_handles_count());
38
39 echo "Done\n";
40 ?>
41 --EXPECTF--
42 %sTEST
43 No free handles!
44 One free request handle within GLOBAL: int(1)
45 Reusing request handle: bool(true)
46 float(%f)
47 float(%f)
48 Handles' been cleaned up:
49 stdClass Object
50 (
51 [http_request] => Array
52 (
53 [GLOBAL] => Array
54 (
55 [used] => 0
56 [free] => 0
57 )
58
59 )
60
61 )
62 Done