8000 [HttpClient] Let curl handle transfer encoding led to a change in behavior · Issue #57544 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[HttpClient] Let curl handle transfer encoding led to a change in behavior #57544
Closed
@ddegasperi

Description

@ddegasperi

Symfony version(s) affected

5.4

Description

With the backport-patch #54517 to symfony 5.4 the http-client sends a empty request body to the server when using a multipart form data.

How to reproduce

With the following code snippet I receive a empty request body on the server:

$formData = new FormDataPart([
    'degree' => '90',
    'file' => new DataPart(
        $fileResource, // a resource not a string
        'image.jpg',
        'image/jpeg'
    )
]);

$response = $client->request('POST', '/api/image/rotate/', [
    'headers' => $formData->getPreparedHeaders()->toArray(),
    'body' => $formData->bodyToIterable(),
]);

The client runs on a server with:
PHP Version: 7.4.33
Curl: 7.61.1

Possible Solution

A possible workaround is to add the following header Transfer-encoding: chunked to the request, but this would break once HTTP/2 protocol is used.

The patch seems to work just with a more recent version of Curl (e.g. 8.8), so an update of this dependency would be another solution

Additional Context

Since Symfony 5.4 is supported also for PHP >=7.2.5, which often runs on systems where dependencies like curl are not necessarily/easaly updatable and I wonder if it was right to backport this patch to this version as it has visibly brought about a change in behavior.

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

      0