Skip to content
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

[HttpClient] Obscure curl error on non successful responses #30753

Closed
Taluu opened this issue Mar 28, 2019 · 1 comment
Closed

[HttpClient] Obscure curl error on non successful responses #30753

Taluu opened this issue Mar 28, 2019 · 1 comment

Comments

@Taluu
Copy link
Contributor

Taluu commented Mar 28, 2019

Symfony version(s) affected: master / 4.3

Description
If you are using the brand new symfony http client, and the request fails for some reasons (e.g a 400 or a 500 is returned), instead of having a neat http client exception stating that we had a 400 or a 500, we have a TransportException with an obscure curl error message (failed writing headers).

If we add a call to getStatusCode, the exception disappear (as expected). This seems to happen only with a request returning a body within the response with the status code and currently I managed to reproduce it only with a application/json content type.

How to reproduce
See my reproducer : https://gist.github.com/Taluu/50aa950b4fcfd5997f69e1d11ead6cdf

Possible Solution
No idea. :D

@nicolas-grekas
Copy link
Member

good catch thx for the reproducer.

nicolas-grekas added a commit that referenced this issue Mar 28, 2019
…onse (nicolas-grekas)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[HttpClient] correctly clean state on destruct in CurlResponse

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30753
| License       | MIT
| Doc PR        | -

On destruct, we ask curl to close the stream once the headers arrived, but we don't silence the "error" this sets in curl. This fixes it.

Commits
-------

332a88c [HttpClient] correctly clean state on destruct in CurlResponse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants