diff --git a/src/Message/ServerRequest.php b/src/Message/ServerRequest.php index a46ed1f..4329901 100644 --- a/src/Message/ServerRequest.php +++ b/src/Message/ServerRequest.php @@ -465,7 +465,11 @@ class ServerRequest extends Request implements ServerRequestInterface */ protected function getStreamForBody() { - return new Stream(fopen("php://input", "r")); + $input = fopen("php://input", "rb"); + $temp = fopen("php://temp", "wb+"); + stream_copy_to_stream($input, $temp); + rewind($temp); + return new Stream($temp); } /** diff --git a/src/Message/Stream.php b/src/Message/Stream.php index 1491bd6..61be3b1 100644 --- a/src/Message/Stream.php +++ b/src/Message/Stream.php @@ -52,7 +52,9 @@ class Stream implements StreamInterface rewind($this->resource); } $string = $this->getContents(); + // @codeCoverageIgnoreStart } catch (\Exception $e) { + // @codeCoverageIgnoreEnd // Silence exceptions in order to conform with PHP's string casting operations. } return $string;