X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=tests%2Fproxy.inc;h=61b20dd1c1b38e3a26190d5d401216387991bc07;hb=8a3ddf26349337c2c42dc2716bb4b3e93bded96c;hp=89d31f4c53408f62343d0d35190c1a416802808f;hpb=22d8bd9cce8969e37269f1e817da0904a6af522c;p=m6w6%2Fext-http diff --git a/tests/proxy.inc b/tests/proxy.inc index 89d31f4..61b20dd 100644 --- a/tests/proxy.inc +++ b/tests/proxy.inc @@ -1,26 +1,21 @@ getHeader("Proxy-Connection")) { - $response = new http\Env\Response; - $response->setHeader("Content-Length", 0); - $response->send($client); - - /* soak up the request following the connect */ - new http\Message($client, false); - } - - /* return the initial message as response body */ - $response = new http\Env\Response; - $response->getBody()->append($request); - $response->send($client); - } - return; +include "server.inc"; + +serve(function($client) { + /* this might be a proxy connect or a standard request */ + $request = new http\Message($client, false); + + if ($request->getHeader("Proxy-Connection")) { + $response = new http\Env\Response; + $response->send($client); + + /* soak up the request following the connect */ + new http\Message($client, false); } -} \ No newline at end of file + + /* return the initial message as response body */ + $response = new http\Env\Response; + $response->getBody()->append($request); + $response->send($client); +});