Skip to content

[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

Merged
merged 1 commit into from
Jul 8, 2019

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Jun 30, 2019

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.

@nicolas-grekas nicolas-grekas force-pushed the hc-stream branch 11 times, most recently from 6ae8295 to 24ff118 Compare July 4, 2019 17:34
@fabpot
Copy link
Member

fabpot commented Jul 5, 2019

Looks like fabbot has something interesting to say.

@nicolas-grekas
Copy link
Member Author

Oups, fabbot patch now applied.

@fabpot
Copy link
Member

fabpot commented Jul 8, 2019

Thank you @nicolas-grekas.

@fabpot fabpot merged commit a59e0af into symfony:4.4 Jul 8, 2019
fabpot added a commit that referenced this pull request Jul 8, 2019
…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
Copy link

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 ?

Copy link

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.

@nicolas-grekas nicolas-grekas deleted the hc-stream branch July 19, 2019 11:11
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
This was referenced Nov 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants