Skip to content

[HttpClient] Content-length is not send anymore by CurlClient #45841

@jderusse

Description

@jderusse

Symfony version(s) affected

dev

Description

Since #45814 the content-length header is not sent anymore which breaks calls to servers that expect this header.

I noticed this bug in async-aws test suite https://github.com/async-aws/aws/runs/5681048314?check_suite_focus=true#step:8:143

By inspecting the trace $response->info(), I get:

    *   Trying ::1:4569...\n
    * connect to ::1 port 4569 failed: Connection refused\n
    *   Trying 127.0.0.1:4569...\n
    * Connected to localhost (127.0.0.1) port 4569 (#0)\n
    > PUT /foo/bar/ HTTP/1.1\r\n
    Host: localhost:4569\r\n
    Accept: */*\r\n
    User-Agent: Symfony HttpClient/Curl\r\n
    Accept-Encoding: gzip\r\n
    \r\n
    * Mark bundle as not supporting multiuse\n
    < HTTP/1.1 411 Length Required \r\n
    < Content-Type: text/html; charset=ISO-8859-1\r\n
    < Access-Control-Allow-Origin: *\r\n
    < Server: WEBrick/1.3.1 (Ruby/2.1.5/2014-11-13) OpenSSL/1.0.1t\r\n
    < Date: Thu, 24 Mar 2022 19:29:33 GMT\r\n
    < Content-Length: 318\r\n
    < Connection: close\r\n
    < \r\n
    * Closing connection 0\n

As you can see, content-length header is missing.

$ php -v
PHP 8.1.4 (cli) (built: Mar 20 2022 16:52:39) (NTS)
$ php --ri curl
cURL support => enabled
cURL Information => 7.74.0

How to reproduce

initialize a reproducer

git clone git@github.com:async-aws/aws.git
cd aws/src/Service/S3/
composer config minimum-stability dev
composer up
composer req symfony/phpunit-bridge

run tests

make test

or to run only 1 test

make start-docker
./vendor/bin/simple-phpunit  --filter testCreateDirectory

edit file core/src/Response.php in defineResolveStatus to add debug informations

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions