Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MatTheCat opened this issue Aug 12, 2023 · 2 comments
Closed

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

MatTheCat opened this issue Aug 12, 2023 · 2 comments

Comments

@MatTheCat
Copy link
Contributor

MatTheCat commented Aug 12, 2023

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.

@rskuipers
Copy link

I'm running into this issue right now, but I'm unsure as to how I can work around this? If it's even possible to workaround this right now...

@AlexaneTrubert
Copy link

Have same issue, is there any solution ?

@MatTheCat MatTheCat changed the title [HttpClient] Upload streams check inconsistencies [HttpClient] Uploading files causes the data collector to crash Nov 6, 2023
nicolas-grekas added a commit that referenced this issue Nov 6, 2023
…nd when files are uploaded (MatTheCat)

This PR was merged into the 6.3 branch.

Discussion
----------

[HttpClient][WebProfilerBundle] Do not generate cURL command when files are uploaded

| Q             | A
| ------------- | ---
| Branch?       | 6.3
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #51366
| License       | MIT

I also removed ``@requires` extension openssl` annotations since that does not seem to be the case since #45729.

Failures in AppVeyor occur because double quotes are missing around `--data-raw` values. Possibly related to #52429.

Commits
-------

4503f94 [HttpClient][WebProfilerBundle] Do not generate cURL command when files are uploaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants