9666b976a618a6f297df56448ac70df54ae18c58
[m6w6/ext-http] / tests / client019.phpt
1 --TEST--
2 client proxy - send proxy headers for a proxy request
3 --SKIPIF--
4 <?php
5 include "skipif.inc";
6 skip_client_test();
7 $client = new http\Client("curl");
8 array_key_exists("proxyheader", $client->getAvailableOptions())
9 or die("skip need libcurl with CUTLOPT_PROXYHEADER support\n");
10 ?>
11 --FILE--
12 <?php
13
14 include "helper/server.inc";
15
16 echo "Test\n";
17
18 server("proxy.inc", function($port, $stdin, $stdout, $stderr) {
19 echo "Server on port $port\n";
20
21 $c = new http\Client;
22 $r = new http\Client\Request("GET", "http://www.example.com/");
23 $r->setOptions(array(
24 "timeout" => 10,
25 "proxytunnel" => true,
26 "proxyheader" => array("Hello" => "there!"),
27 "proxyhost" => "localhost",
28 "proxyport" => $port,
29 ));
30 try {
31 $c->enqueue($r)->send();
32 } catch (Exception $e) {
33 echo $e;
34 }
35 echo $c->getResponse()->getBody();
36 });
37
38 ?>
39 ===DONE===
40 --EXPECTF--
41 Test
42 Server on port %d
43 CONNECT www.example.com:80 HTTP/1.1
44 Hello: there!
45 Host: www.example.com:80
46 Proxy-Connection: Keep-Alive
47 User-Agent: PECL_HTTP/%s PHP/%s libcurl/%s
48
49 ===DONE===