-
-
Notifications
You must be signed in to change notification settings - Fork 57
Add support for streamed response #50
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
Add support for streamed response #50
Conversation
It seems like Travis is happy but fabbot.io failed with "Not Found" 🤔 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, can you just run PHP CS Fixer please.
@dunglas done :) |
Factory/HttpFoundationFactory.php
Outdated
@@ -140,11 +154,12 @@ protected function getTemporaryPath() | |||
*/ | |||
public function createResponse(ResponseInterface $psrResponse) | |||
{ | |||
$response = new Response( | |||
$psrResponse->getBody()->__toString(), | |||
$response = new StreamedResponse( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should use stream responses in every possible cases because StreamedResponse
have some downsides like preventing the debug toolbar from being injected.
Can this be made configurable ?
What about this PR ? Is it still relevant ? This is a nice feature to add in this component. |
Maybe by creating a another method ? Don't touch |
@danizord do you need help to finish this PR ? |
0c60565
to
013db27
Compare
013db27
to
7cc1605
Compare
I rebased the PR and made the behavior opt-in by adding a new |
Thank you @danizord. |
This PR was merged into the 1.2-dev branch. Discussion ---------- Add support for streamed response Here's a simple implementation of response streaming heavily inspired by Diactoros' response emitter, using HttpFoundation's `StreamedResponse`. It lacks support for `Content-Range`, but I can provide that in a future PR. Closes https://github.com/symfony/psr-http-message-bridge/issues/3 Commits ------- 7cc1605 Add support for streamed response
This PR was squashed before being merged into the 1.2-dev branch. Discussion ---------- Add support for streamed Symfony request As a continuation of #3 and #50 . Add support for converting a `ServerRequestInterface` with a large body to a Symfony request. I'm not all too familiar with Symfony components, but I saw that a Symfony request supports `string|resource|null` as its body. Since calling `detach()` on a `StreamInterface` will make the stream unsuable I added a `$streamed` argument to the function in order to not make break any existing code, and to make it a conscious decision of the caller to stream the response. I'm happy to make any necessary changes if needed. Commits ------- df26630 Add support for streamed Symfony request
Here's a simple implementation of response streaming heavily inspired by Diactoros' response emitter, using HttpFoundation's
StreamedResponse
. It lacks support forContent-Range
, but I can provide that in a future PR.Closes https://github.com/symfony/psr-http-message-bridge/issues/3