From aba1f7d332d866ca1f0397d46751864e430985f3 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 12 Feb 2015 11:14:04 +0100 Subject: [PATCH] yep, moved there. ugh --- tests/helper/cookie.inc | 11 +++++++++++ tests/helper/pipeline.inc | 25 ++++++++++++++++++++++++ tests/helper/proxy.inc | 21 ++++++++++++++++++++ tests/helper/server.inc | 41 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) create mode 100644 tests/helper/cookie.inc create mode 100644 tests/helper/pipeline.inc create mode 100644 tests/helper/proxy.inc create mode 100644 tests/helper/server.inc diff --git a/tests/helper/cookie.inc b/tests/helper/cookie.inc new file mode 100644 index 0000000..d33666b --- /dev/null +++ b/tests/helper/cookie.inc @@ -0,0 +1,11 @@ +getHeader("cookie")); + $response = new http\Env\Response; + $response->setCookie($cookies->setCookie("counter", $cookies->getCookie("counter")+1)); + $response->send($client); +}); diff --git a/tests/helper/pipeline.inc b/tests/helper/pipeline.inc new file mode 100644 index 0000000..815b463 --- /dev/null +++ b/tests/helper/pipeline.inc @@ -0,0 +1,25 @@ +setEnvRequest($msg) + ->setHeader("X-Req", $msg->getRequestUrl()) + ->send($client); +} + +serve(function($client) { + $count = trim(fgets(STDIN)); + + /* the peek message */ + respond($client, new http\Message($client, false)); + + /* pipelined messages */ + $req = array(); + for ($i=0; $i < $count; ++ $i) { + $req[] = new http\Message($client, false); + } + foreach ($req as $msg) { + respond($client, $msg); + } +}); diff --git a/tests/helper/proxy.inc b/tests/helper/proxy.inc new file mode 100644 index 0000000..61b20dd --- /dev/null +++ b/tests/helper/proxy.inc @@ -0,0 +1,21 @@ +getHeader("Proxy-Connection")) { + $response = new http\Env\Response; + $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); +}); diff --git a/tests/helper/server.inc b/tests/helper/server.inc new file mode 100644 index 0000000..70fb7cf --- /dev/null +++ b/tests/helper/server.inc @@ -0,0 +1,41 @@ +