diff options
Diffstat (limited to 'tests/http')
-rw-r--r-- | tests/http/echoDelay.php | 11 | ||||
-rw-r--r-- | tests/http/payload.php | 5 | ||||
-rw-r--r-- | tests/http/pid.php | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/tests/http/echoDelay.php b/tests/http/echoDelay.php new file mode 100644 index 00000000..2ee2b049 --- /dev/null +++ b/tests/http/echoDelay.php @@ -0,0 +1,11 @@ +<?php + +use \Psr\Http\Message\ServerRequestInterface; +use \Psr\Http\Message\ResponseInterface; + +function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface +{ + sleep(1); + $resp->getBody()->write(strtoupper($req->getQueryParams()['hello'])); + return $resp->withStatus(201); +}
\ No newline at end of file diff --git a/tests/http/payload.php b/tests/http/payload.php index a16984c5..52c0f819 100644 --- a/tests/http/payload.php +++ b/tests/http/payload.php @@ -5,6 +5,11 @@ use Psr\Http\Message\ServerRequestInterface; function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface { + if ( $req->getHeaderLine("Content-Type") != 'application/json' ) { + $resp->getBody()->write("invalid content-type"); + return $resp; + } + // we expect json body $p = json_decode($req->getBody(), true); $resp->getBody()->write(json_encode(array_flip($p))); diff --git a/tests/http/pid.php b/tests/http/pid.php index 1cc322bf..0c9a4e4d 100644 --- a/tests/http/pid.php +++ b/tests/http/pid.php @@ -5,7 +5,7 @@ use Psr\Http\Message\ServerRequestInterface; function handleRequest(ServerRequestInterface $req, ResponseInterface $resp): ResponseInterface { - $resp->getBody()->write(getmypid()); + $resp->getBody()->write((string)getmypid()); return $resp; }
\ No newline at end of file |