-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Add $response->toStream() to cast responses to regular PHP streams #32290
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
dcd5496
to
764043e
Compare
764043e
to
7c78618
Compare
6ae8295
to
24ff118
Compare
Looks like fabbot has something interesting to say. |
Oups, fabbot patch now applied. |
Thank you @nicolas-grekas. |
…es to regular PHP streams (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] Add $response->toStream() to cast responses to regular PHP streams | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This PR adds `$response->toStream()` to cast responses to regular PHP streams, and uses the method in `Psr18Client` and `HttplugClient`. This means `Psr18Client` and `HttplugClient` will now be lazy past response headers. I'm not sure any other PSR-18 implementation has this behavior. :) This also adds `StreamWrapper::createResource()` to turn any `ResponseInterface` implementation into a PHP stream. /cc @Nyholm FYI since we discussed about this recently. Commits ------- a59e0af [HttpClient] Add $response->toStream() to cast responses to regular PHP streams
} | ||
} | ||
|
||
public function stream_open(string $path, string $mode, int $options): bool |
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.
Is this purposeful that the methods are stream_open
and not streamOpen
. I see this is mixed now . Accidental ?
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.
My bad, I see where this is ending up. https://www.php.net/manual/en/stream.streamwrapper.example-1.php . Sorry about the comment.
This PR adds
$response->toStream()
to cast responses to regular PHP streams, and uses the method inPsr18Client
andHttplugClient
.This means
Psr18Client
andHttplugClient
will now be lazy past response headers. I'm not sure any other PSR-18 implementation has this behavior. :)This also adds
StreamWrapper::createResource()
to turn anyResponseInterface
implementation into a PHP stream./cc @Nyholm FYI since we discussed about this recently.