From 4162daad52e61caa251533df1d78c9f9c000de7f Mon Sep 17 00:00:00 2001 From: Thomas Flori <t.flori@sportradar.com> Date: Tue, 9 Jul 2019 14:27:44 +0200 Subject: [PATCH] fix: wrap input stream with caching stream This stream does not support seek and so we wrap it in caching stream to be able to reread the body of a request. --- src/ServerRequest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ServerRequest.php b/src/ServerRequest.php index 486dbc8..5d1ccc3 100644 --- a/src/ServerRequest.php +++ b/src/ServerRequest.php @@ -2,6 +2,7 @@ namespace Tal; +use GuzzleHttp\Psr7\CachingStream; use GuzzleHttp\Psr7\LazyOpenStream; use GuzzleHttp\Psr7\UploadedFile; use GuzzleHttp\Psr7\Uri; @@ -171,7 +172,7 @@ class ServerRequest extends Request implements ServerRequestInterface $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; $headers = function_exists('getallheaders') ? getallheaders() : []; $uri = self::getUriFromGlobals(); - $body = new LazyOpenStream('php://input', 'r+'); + $body = new CachingStream(new LazyOpenStream('php://input', 'r+')); $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; $serverRequest = new static($method, $uri, $headers, $body, $protocol, $_SERVER); -- GitLab