-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[HttpKernel] Fix StreamedResponse with chunks support in HttpKernelBrowser #62036
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
Conversation
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.
Looks good to me.
I revised my mind because the failing tests are due to this PR.
- The
ob_startcallback shall return a string but here nothing is returned. - Also, in case of an exception the buffer is still open.
The current behavious is not perfect because of the last bullet.
A possible solution:
$content = '';
ob_start(static function (string $chunk, int $phase): string {
return $chunk;
});
try {
$response->sendContent();
$buffered = ob_get_contents();
} finally {
ob_end_clean();
}
$final = $buffered !== false ? $buffered : $content;@mtarld any thoughts on this PR?
d9ab24c to
7bfcc2c
Compare
7bfcc2c to
4c27082
Compare
4c27082 to
fd8fb64
Compare
fd8fb64 to
2932941
Compare
|
Thank you @wuchen90. |
|
Hi @nicolas-grekas, As mentioned in #62036 (review), ob_start callback is expected to return a |
|
I fixed this concern in bfe4671 |
|
I missed it. Thank you for the clarification. |
|
This change broke our tests, we loosely have a test like that ob_start();
$client->request('GET', "/photos/$slug");
$content = ob_get_clean();With this refactor the $content is empty. I don't know if the iterator should be rewinded. |
This PR fixes changes done in #60262 that breaks
HttpKernelBrowserwhen it comes to deal withStreamedResponsecreated with an iterator.