- add pers. handles test
[m6w6/ext-http] / tests / persistent_handles_001.phpt
1 --TEST--
2 persistent handles
3 --SKIPIF--
4 <?php
5 include 'skip.inc';
6 skipif(!defined("HTTP_SUPPORT_PERSISTENCE") || !http_support(HTTP_SUPPORT_PERSISTENCE), "need persistent handle support");
7 ?>
8 --INI--
9 http.persistent.handles.ident=GLOBAL
10 --FILE--
11 <?php
12 echo "-TEST\n";
13
14 echo "No free handles:\n";
15 var_dump(http_persistent_handles_count());
16 http_get("http://www.google.com/", null, $info[]);
17 echo "One free request handle within GLOBAL:\n";
18 var_dump(http_persistent_handles_count()->http_request["GLOBAL"]);
19 echo "Reusing request handle:\n";
20 http_get("http://www.google.com/", null, $info[]);
21 var_dump($info[0]["pretransfer_time"] > 100 * $info[1]["pretransfer_time"], $info[0]["pretransfer_time"], $info[1]["pretransfer_time"]);
22 echo "Handles' been cleaned up:\n";
23 #http_persistent_handles_clean();
24 var_dump(http_persistent_handles_count());
25 echo "Done\n";
26 ?>
27 --EXPECTF--
28 %sTEST
29 No free handles:
30 object(stdClass)#%d (%d) {
31 ["http_request_pool"]=>
32 array(0) {
33 }
34 ["http_request"]=>
35 array(0) {
36 }
37 ["http_request_datashare"]=>
38 array(0) {
39 }
40 ["http_request_datashare_lock"]=>
41 array(0) {
42 }
43 }
44 One free request handle within GLOBAL:
45 int(1)
46 Reusing request handle:
47 bool(true)
48 float(%f)
49 float(%f)
50 Handles' been cleaned up:
51 object(stdClass)#%d (%d) {
52 ["http_request_pool"]=>
53 array(0) {
54 }
55 ["http_request"]=>
56 array(1) {
57 ["GLOBAL"]=>
58 int(1)
59 }
60 ["http_request_datashare"]=>
61 array(0) {
62 }
63 ["http_request_datashare_lock"]=>
64 array(0) {
65 }
66 }
67 Done