ensure options are applied before the headers are set
[m6w6/ext-http] / tests / proxy.inc
1 <?php
2
3 foreach (range(8000, 9000) as $port) {
4 if (($server = stream_socket_server("tcp://localhost:$port"))) {
5 fprintf(STDERR, "%s\n", $port);
6 if (($client = stream_socket_accept($server))) {
7 /* this might be a proxy connect or a standard request */
8 $request = new http\Message($client, false);
9
10 if ($request->getHeader("Proxy-Connection")) {
11 $response = new http\Env\Response;
12 $response->setHeader("Content-Length", 0);
13 $response->send($client);
14
15 /* soak up the request following the connect */
16 new http\Message($client, false);
17 }
18
19 /* return the initial message as response body */
20 $response = new http\Env\Response;
21 $response->getBody()->append($request);
22 $response->send($client);
23 }
24 return;
25 }
26 }