Skip to content

[Http-Client] #46499

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

Closed
Iyadhfaleh opened this issue May 30, 2022 · 6 comments
Closed

[Http-Client] #46499

Iyadhfaleh opened this issue May 30, 2022 · 6 comments

Comments

@Iyadhfaleh
Copy link

Iyadhfaleh commented May 30, 2022

Symfony version(s) affected

4.4.39

Description

We faced a bug after upgrading Http-client from 4.4.35 to >= 4.4.39

How to reproduce

We are using this configuration of our service :

our.client: base_uri: 'https://lorem-ipsum.com' proxy: 'http://proxy.net:8080' headers: Accept: 'application/json'

And we make calls like bellow :
$response = $this->client->request(Request::METHOD_POST, 'token', [ 'body' => [ 'username' => $userName, 'password' => $password, 'grant_type' =>password, 'client_id' => $clientId, 'client_secret' => $client_secret, ], ]); $result = $response->toArray();

We received this exception Failure when receiving data from the peer for ...

Possible Solution

No response

Additional Context

No response

@xabbuh
Copy link
Member

xabbuh commented May 30, 2022

Can you create a small example application that allows to reproduce your issue?

@Iyadhfaleh
Copy link
Author

Iyadhfaleh commented May 30, 2022

@xabbuh

In services.yaml , we configured it like this :

        scoped_clients:
              our_client.client:
                base_uri: 'https://lorem-ipsum.com' 
                proxy: 'http://proxy.net:8080'
                headers: Accept: 'application/json'
        ```
        
     And we make calls like this : 
     
     ```
        $response = $this->ourClientClient->request(Request::METHOD_POST, 'token', [
                'body' => [
                    'username' => $userName,
                    'password' => $password,
                    'grant_type' => 'password',
                    'client_id' => $clientId,
                    'client_secret' => $clientSecret
                ],
            ]);

            $result = $response->toArray();
            ```

 PS : with native curl calls works without problems 

@xabbuh
Copy link
Member

xabbuh commented May 30, 2022

I am afraid one needs a full example application that one can just clone and run to reproduce the error.

@nicolas-grekas
Copy link
Member

Sending option body without a Content-Type means you're sending the data as application/x-www-form-urlencoded. Is this really what your API expects? Can you figure out the exact version or even commit that introduced the change for you?

@xabbuh
Copy link
Member

xabbuh commented Jun 10, 2022

I am going to close here for now due to the lack of feedback. Please let us know when you have more information and we can consider to reopen.

@nicolas-grekas
Copy link
Member

Should be fixed by #48966. If you have the opportunity, please give it a try and report back.

nicolas-grekas added a commit that referenced this issue Jan 13, 2023
…as-grekas)

This PR was merged into the 5.4 branch.

Discussion
----------

[HttpClient] Let curl handle content-length headers

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #47973, #46499, #46823
| License       | MIT
| Doc PR        | -

I'm not sure why (maybe some older and buggy curl versions?) but it looks like curl might send content-length headers to proxies.

This didn't happen before #45261 so I'm trying to use curl in the same was as we did by the time, aka letting it handle content-length header when possible.

This is something that I already attempted in #45814 but was partly reverted in #45998. The attached patch is free from such issue.

Commits
-------

5b27dc2 [HttpClient] Let curl handle content-length headers
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

4 participants