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);
10 if ($request->getHeader("Proxy-Connection")) {
11 $response = new http\Env\Response;
12 $response->setHeader("Content-Length", 0);
13 $response->send($client);
15 /* soak up the request following the connect */
16 new http\Message($client, false);
19 /* return the initial message as response body */
20 $response = new http\Env\Response;
21 $response->getBody()->append($request);
22 $response->send($client);