CURLOPT_PROXYHEADER support; default chunked encoding for stream
[m6w6/ext-http] / tests / proxy001.phpt
1 --TEST--
2 proxy - send proxy headers for a proxy request
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 skip_client_test();
7 ?>
8 --FILE--
9 <?php
10
11 echo "Test\n";
12
13 $spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
14 if (($proc = proc_open(PHP_BINARY . " proxy.inc", $spec, $pipes, __DIR__))) {
15 $port = trim(fgets($pipes[2]));
16 echo "Server on port $port\n";
17 $c = new http\Client;
18 $r = new http\Client\Request("GET", "http://www.example.com/");
19 $r->setOptions(array(
20 "timeout" => 3,
21 "proxytunnel" => true,
22 "proxyheader" => array("Hello" => "there!"),
23 "proxyhost" => "localhost",
24 "proxyport" => $port,
25 ));
26 try {
27 $c->enqueue($r)->send();
28 } catch (Exception $e) {
29 echo $e;
30 }
31 echo $c->getResponse()->getBody();
32 while (!feof($pipes[1])) {
33 echo fgets($pipes[1]);
34 }
35 unset($r, $client);
36 }
37 ?>
38 ===DONE===
39 --EXPECTF--
40 Test
41 Server on port %d
42 CONNECT www.example.com:80 HTTP/1.1
43 Host: www.example.com:80
44 User-Agent: PECL_HTTP/%s PHP/%s libcurl/%s
45 Proxy-Connection: Keep-Alive
46 Hello: there!
47 Content-Length: 0
48 ===DONE===