Skip to content

[HttpClient] Let curl handle transfer encoding led to a change in behavior #57544

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy