-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Inconsistent interface for adding headers with/out file uploads #38082
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
Comments
Another example for 3 would be |
Yes. all syntaxes are allowed exactly for this: to ease with different styles depending on the situation. Consistency is on the side of the consumer, if it matters.
Could be added to the
there is another way that frees us from having a mutable service (which would be no-go): use decoration. Something like that: $configuredClient = new ScopingHttpClient($injectedClient, ['.*' => ['headers' => ['User-Agent' => 'foo']]]); If this is common enough, we might consider a factory method in |
Integrating the findings of symfony/symfony#38082 (comment)
Closing as explained. |
This PR was merged into the 4.4 branch. Discussion ---------- Update http_client.rst Integrating the findings of symfony/symfony#38082 (comment) Commits ------- c8e5dd6 Update http_client.rst
Description
Usually you add a header like this - see https://symfony.com/doc/current/http_client.html#headers
But how can you add a header when doing a file upload? https://symfony.com/doc/current/http_client.html#uploading-data doesn't say anything about this, so I'm guessing:
Questions:
addHeader
method that works in all cases?framework.yaml
for the client (not the request). My use case: I'm doing$client-request()
multiple times, and I need the same User-Agent for all of them. The string is dynamic (so I can't set it inframework.yaml
), but it's the same for every PHP session, so something like$client->setOptions(...)
would work.The text was updated successfully, but these errors were encountered: