PhpInputStream is currently using private cache property to store the content of php://input stream in order to allow multiple uses of __toString(). String PhpInputStream::$cache means that potentially large raw request body is read fully into memory.
PhpInputStream can benefit from this as well. Potentially, to avoid unnecessary performance hit stream can be copied and replaced internally only when metadata or content is accessed for the first time.
Additionally, because php://input stream can not be used with fstat() the PhpInputStream::getSize() currently always returns null. See #2 This change will provide support for getting body size.
Feature Request
Summary
PhpInputStream
is currently using private cache property to store the content ofphp://input
stream in order to allow multiple uses of__toString()
. StringPhpInputStream::$cache
means that potentially large raw request body is read fully into memory.As @boesing pointed out, guzzle reads content of
php://input
intophp://temp
which then in turn allows full utilization of stream features such as ability to seek, rewind, read in chunks, read multiple times. See https://github.com/guzzle/psr7/blob/fe18df3deb34d1e0eab8a63ef4fe2aeb2a8e8c94/src/Utils.php#L305-L310PhpInputStream
can benefit from this as well. Potentially, to avoid unnecessary performance hit stream can be copied and replaced internally only when metadata or content is accessed for the first time.Additionally, because
php://input
stream can not be used withfstat()
thePhpInputStream::getSize()
currently always returns null. See #2 This change will provide support for getting body size.Will fix #150 if adopted.