ServerRequest copies request body to temp stream to allow multiple reads
This commit is contained in:
parent
50f1004be5
commit
b8b87a8032
|
|
@ -465,7 +465,11 @@ class ServerRequest extends Request implements ServerRequestInterface
|
||||||
*/
|
*/
|
||||||
protected function getStreamForBody()
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,9 @@ class Stream implements StreamInterface
|
||||||
rewind($this->resource);
|
rewind($this->resource);
|
||||||
}
|
}
|
||||||
$string = $this->getContents();
|
$string = $this->getContents();
|
||||||
|
// @codeCoverageIgnoreStart
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
// @codeCoverageIgnoreEnd
|
||||||
// Silence exceptions in order to conform with PHP's string casting operations.
|
// Silence exceptions in order to conform with PHP's string casting operations.
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue