Merge branch 'v2.6.x' of github.com:m6w6/ext-http
[m6w6/ext-http] / tests / client021.phpt
1 --TEST--
2 client cookies
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 skip_client_test();
7 ?>
8 --FILE--
9 <?php
10
11 include "helper/server.inc";
12
13 echo "Test\n";
14
15 function dump($f) {
16 return;
17 readfile($f);
18 }
19
20 $tmpfile = tempnam(sys_get_temp_dir(), "cookie.");
21 $request = new http\Client\Request("GET", "http://localhost");
22 $request->setOptions(array("cookiestore" => $tmpfile));
23
24 server("cookie.inc", function($port) use($request, $tmpfile) {
25 $request->setOptions(array("port" => $port));
26 $client = new http\Client;
27 echo $client->requeue($request)->send()->getResponse();
28 #dump($tmpfile);
29 echo $client->requeue($request)->send()->getResponse();
30 #dump($tmpfile);
31 echo $client->requeue($request)->send()->getResponse();
32 #dump($tmpfile);
33 });
34 server("cookie.inc", function($port) use($request, $tmpfile) {
35 $request->setOptions(array("port" => $port));
36 $client = new http\Client;
37 echo $client->requeue($request)->send()->getResponse();
38 #dump($tmpfile);
39 echo $client->requeue($request)->send()->getResponse();
40 #dump($tmpfile);
41 echo $client->requeue($request)->send()->getResponse();
42 #dump($tmpfile);
43 });
44
45 server("cookie.inc", function($port) use($request, $tmpfile) {
46 $request->setOptions(array("port" => $port, "cookiesession" => true));
47 $client = new http\Client;
48 echo $client->requeue($request)->send()->getResponse();
49 dump($tmpfile);
50 echo $client->requeue($request)->send()->getResponse();
51 dump($tmpfile);
52 echo $client->requeue($request)->send()->getResponse();
53 dump($tmpfile);
54 });
55
56 server("cookie.inc", function($port) use($request, $tmpfile) {
57 $request->setOptions(array("port" => $port, "cookiesession" => false));
58 $client = new http\Client;
59 echo $client->requeue($request)->send()->getResponse();
60 dump($tmpfile);
61 echo $client->requeue($request)->send()->getResponse();
62 dump($tmpfile);
63 echo $client->requeue($request)->send()->getResponse();
64 dump($tmpfile);
65 });
66
67 unlink($tmpfile);
68
69 ?>
70 ===DONE===
71 --EXPECT--
72 Test
73 HTTP/1.1 200 OK
74 Set-Cookie: counter=1;
75 Etag: ""
76 X-Original-Transfer-Encoding: chunked
77 HTTP/1.1 200 OK
78 Set-Cookie: counter=2;
79 Etag: ""
80 X-Original-Transfer-Encoding: chunked
81 HTTP/1.1 200 OK
82 Set-Cookie: counter=3;
83 Etag: ""
84 X-Original-Transfer-Encoding: chunked
85 HTTP/1.1 200 OK
86 Set-Cookie: counter=4;
87 Etag: ""
88 X-Original-Transfer-Encoding: chunked
89 HTTP/1.1 200 OK
90 Set-Cookie: counter=5;
91 Etag: ""
92 X-Original-Transfer-Encoding: chunked
93 HTTP/1.1 200 OK
94 Set-Cookie: counter=6;
95 Etag: ""
96 X-Original-Transfer-Encoding: chunked
97 HTTP/1.1 200 OK
98 Set-Cookie: counter=1;
99 Etag: ""
100 X-Original-Transfer-Encoding: chunked
101 HTTP/1.1 200 OK
102 Set-Cookie: counter=1;
103 Etag: ""
104 X-Original-Transfer-Encoding: chunked
105 HTTP/1.1 200 OK
106 Set-Cookie: counter=1;
107 Etag: ""
108 X-Original-Transfer-Encoding: chunked
109 HTTP/1.1 200 OK
110 Set-Cookie: counter=2;
111 Etag: ""
112 X-Original-Transfer-Encoding: chunked
113 HTTP/1.1 200 OK
114 Set-Cookie: counter=3;
115 Etag: ""
116 X-Original-Transfer-Encoding: chunked
117 HTTP/1.1 200 OK
118 Set-Cookie: counter=4;
119 Etag: ""
120 X-Original-Transfer-Encoding: chunked
121 ===DONE===
122 --XFAIL--
123 TBD