Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: rewind() after pulling ServerRequest body contents? #102

Open
BusterNeece opened this issue Aug 16, 2019 · 1 comment
Open

Question: rewind() after pulling ServerRequest body contents? #102

BusterNeece opened this issue Aug 16, 2019 · 1 comment

Comments

@BusterNeece
Copy link

BusterNeece commented Aug 16, 2019

I've noticed that in the decorated ServerRequest, when calling getParsedBody, the original body is pulled via (string)$request->getBody(), but the StreamInterface is not rewind-ed after the fact.

In my tests, this means that any call to $request->getBody()->getContents() that takes place after that call happens have the internal stream pointer moved to the end of the input stream, and thus pulls basically always nothing.

I'm not sure if this is just a natural and intended byproduct of how PSR-7's StreamInterface works, or if this is something that could be worked around at this level.

@l0gicgate
Copy link
Member

We're having an ongoing discussion about stream caching. See slimphp/Slim-Psr7#124

This is just for Slim-Psr7 though. As for these decorators I'm thinking that maybe we should also do some automatic caching in order to enable multiple calls to $request->getBody()->getContents()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants