Skip to content
Snippets Groups Projects
Commit 4162daad authored by Thomas Flori's avatar Thomas Flori
Browse files

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.
parent dbfc64ec
No related branches found
Tags v1.0.2
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment