Skip to content

[HttpClient] Uploading files causes the data collector to crash #51366

Closed
@MatTheCat

Description

@MatTheCat

Symfony version(s) affected

≥ 6.3.0

Description

When investigating #51360 I found out the HttpClientTrait::normalizeBody checks if upload streams have ended when they are nested in body (cf. #49911).

In that case, the HttpClientDataCollector will trigger an exception because it will call normalizeBody again when all streams have been read (to generate the cURL command).

How to reproduce

$stream = fopen('filepath', 'r');

$httpClient->request('POST', '/endpoint', [
    'body' => ['stream' => $stream],
]);

will trigger a TransportException if the profiler is enabled.

Possible Solution

The HttpClientDataCollector does not generate a cURL command when the body is a stream, so I guess it shouldn’t either in this case.

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