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