add pipelining test
[m6w6/ext-http] / tests / proxy001.phpt
index c8a2e6308dfed95a7306910e0771a6073f80c820..c3a590517b4d65da8b637f05db266ff76836a831 100644 (file)
@@ -8,20 +8,21 @@ skip_client_test();
 --FILE--
 <?php
 
+include "server.inc";
+
 echo "Test\n";
 
-$spec = array(array("pipe","r"), array("pipe","w"), array("pipe","w"));
-if (($proc = proc_open(PHP_BINARY . " proxy.inc", $spec, $pipes, __DIR__))) {
-       $port = trim(fgets($pipes[2]));
+server("proxy.inc", function($port, $stdin, $stdout, $stderr) {
        echo "Server on port $port\n";
+       
        $c = new http\Client;
        $r = new http\Client\Request("GET", "http://www.example.com/");
        $r->setOptions(array(
-               "timeout" => 3,
-               "proxytunnel" => true,
-               "proxyheader" => array("Hello" => "there!"),
-               "proxyhost" => "localhost",
-               "proxyport" => $port,
+                       "timeout" => 3,
+                       "proxytunnel" => true,
+                       "proxyheader" => array("Hello" => "there!"),
+                       "proxyhost" => "localhost",
+                       "proxyport" => $port,
        ));
        try {
                $c->enqueue($r)->send();
@@ -29,11 +30,9 @@ if (($proc = proc_open(PHP_BINARY . " proxy.inc", $spec, $pipes, __DIR__))) {
                echo $e;
        }
        echo $c->getResponse()->getBody();
-       while (!feof($pipes[1])) {
-               echo fgets($pipes[1]);
-       }
        unset($r, $client);
-}
+});
+
 ?>
 ===DONE===
 --EXPECTF--