-
Notifications
You must be signed in to change notification settings - Fork 42
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
Rewind streams in the formatter #46
Comments
Rewinding the stream is not hard, IF the stream is rewindable :) If not the current design is broken as we have to replace the stream in the request passed to the formatter but since the request is immutable we cannot update the stream easily. Then there is some work to do in the plugin calling the formatter which holds the responsability of rewinding / replacing the stream. |
Also cloning / rewinding the stream is something that it's used in the cache plugin, maybe we can refactor this part to have an helper stream / class doing this ? |
👍 For a helper class doing this. I did the same hack in an other PR: https://github.com/KnpLabs/php-github-api/pull/389/files#diff-192f7f95a475a8e6e67b97d1c5125367R22 Not too sure how to solve the broken design though... Maybe do not read the stream if it not is rewindable/seekable? |
Or copy the stream. |
Or copy the stream.
we should try to avoid that. the memory impact can be massive. i think
we should by default leave the body alone, especially if its not
rewindable, and probably have 3 options: don't show body, show body if
stream can rewind, always show body (and copy streams if needed)
|
This will fix php-http#46
This will fix php-http#46
We cant copy the string because the Request is immutable. I've created a PR. |
* Make sure we rewind stream if we can. This will fix #46 * style fix * Updated changelog with fixes for FullHttpMessageFormatter
Actual Behavior
From: php-http/HttplugBundle#84 (comment)
Expected Behavior
Streams should be rewinded after they are read.
The text was updated successfully, but these errors were encountered: