You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR was squashed before being merged into the 5.4 branch.
Discussion
----------
[HttpClient] Let curl handle transfer encoding
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix#54516, Fix#54491
| License | MIT
Removes the `Transfer-Encoding: chunked` header that is added for chunked request bodies. This will allow curl to handle the transfer encoding and set appropriate headers based on the HTTP protocol version it negotiated with the server, since HTTP/2 does not support chunked transfer encoding.
Commits
-------
69a7867 [HttpClient] Let curl handle transfer encoding
Symfony version(s) affected
7.0
Description
When sending a
FormData
request (and possibly other chunkable body types),CurlHttpClient
will set aTransfer-Encoding: chunked
header:symfony/src/Symfony/Component/HttpClient/CurlHttpClient.php
Lines 254 to 256 in 524c703
Transfer-Encoding
header is set tochunked
explicitly, curl always uses chunked transfer encoding for the body.For example, given a request with
FormData
['foo' => 'bar']
, an HTTP/1 server receives this:While an HTTP/2 server sees this:
How to reproduce
Repo for reproducing the issue:
https://github.com/michaelhue/symfony-curl-http2-chunked-issue
The test source code can be found here:
https://github.com/michaelhue/symfony-curl-http2-chunked-issue/blob/main/test.php
Possible Solution
It seems to me that the following lines can be removed completely, which will fix the issue:
symfony/src/Symfony/Component/HttpClient/CurlHttpClient.php
Lines 254 to 256 in 524c703
However my understanding of
curl
and theSymfony
internals is limited and I can't anticipate the potential fallout from this change.I'd be happy to create a pull request with this solution, if deemed appropriate.
Additional Context
This problem was discovered while trying to debug this issue: #54491
The text was updated successfully, but these errors were encountered: