b7175c109fac1b24d4f4a31e000e08cda288ae4d
[m6w6/ext-http] / tests / helper / pipeline.inc
1 <?php
2
3 include "server.inc";
4
5 function respond($client, $msg) {
6 $r = new http\Env\Response;
7 $r->setEnvRequest($msg)
8 ->setHeader("X-Req", $msg->getRequestUrl())
9 ->send($client);
10 }
11
12 serve(function($client) {
13 $count = trim(fgets(STDIN));
14
15 /* the peek message */
16 respond($client, new http\Message($client, false));
17
18 /* pipelined messages */
19 $req = array();
20 for ($i=0; $i < $count; ++ $i) {
21 $req[] = new http\Message($client, false);
22 }
23 foreach ($req as $msg) {
24 respond($client, $msg);
25 }
26 });