5 function respond($client, $msg) {
6 $r = new http\Env\Response;
7 $r->setEnvRequest($msg)
8 ->setHeader("X-Req", $msg->getRequestUrl())
12 serve(function($client) {
13 $count = trim(fgets(STDIN));
14 logger("Expecting %d messages", $count);
15 /* the peek message */
16 respond($client, new http\Message($client, false));
17 logger("Handled the peek request");
18 /* pipelined messages */
20 for ($i=0; $i < $count; ++ $i) {
21 $req[] = new http\Message($client, false);
22 logger("Read request no. %d", $i+1);
24 foreach ($req as $i => $msg) {
25 respond($client, $msg);
26 logger("Sent response no. %d", $i+1);