-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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] Add an opportunity to use curl BLOB constants certs #48775
[HttpClient] Add an opportunity to use curl BLOB constants certs #48775
Conversation
…O`, `SSLCERT`, `SSLKEY`
I don't think we should have the same option supporting strings being either filesystem paths or file contents. Guessing the expected signature based on whether the file actually exists is quite fragile (and might even be dangerous) |
Ok, I agree. To be honest, initially, I wanted to introduce new options, but I spent some time thinking about naming and finished with no good idea :) What do you think about the next naming: Also, I didn't get why the tests failed with the |
…O`, `SSLCERT`, `SSLKEY`
…`cafile`, `local_cert` and `local_pk` options as raw content instead of path to file
Thanks for the PR. |
But in that case, we need to do it in every request, if I understand correctly. |
It should be possible to configure default "extra" entries. If that's not possible today, this should be improved. |
Okay, will do it in a separate PR |
Thanks. Note that you can also configure the default options at the injection point, with eg |
Yes, it's applicable, but again in that case we need to do it in every class we use those options :( |
Closing in favor of #48797 |
… Configuration (voodooism) This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [FrameworkBundle] Add `extra` attribute for HttpClient Configuration | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT | Doc PR | coming soon...<!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry sh - ould follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> I want to configure HttpClient once in configure file and forget about the configuration when doing a request or injection. In my particular case, I want to pass certificates to the client as raw values using special curlopts. Here #48775 proposed the best way to do it - using `extra` attribute in configuration. It's going to look like so ```php return static function (FrameworkConfig $frameworkConfig): void { $httpClient = $frameworkConfig->httpClient(); $httpClient->defaultOptions([ 'extra' => ['curl' => ['foo' => 'bar']] ]); $httpClient->scopedClient('some_client') ->baseUri('https://some.uri') ->header('Accept', 'application/json') ->extra(['curl' => ['foo' => 'bar']]); } ``` Commits ------- 6c89894 [FrameworkBundle] Add `extra` attribute for HttpClient Configuration
… Configuration (voodooism) This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [FrameworkBundle] Add `extra` attribute for HttpClient Configuration | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT | Doc PR | coming soon...<!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry sh - ould follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> I want to configure HttpClient once in configure file and forget about the configuration when doing a request or injection. In my particular case, I want to pass certificates to the client as raw values using special curlopts. Here symfony/symfony#48775 proposed the best way to do it - using `extra` attribute in configuration. It's going to look like so ```php return static function (FrameworkConfig $frameworkConfig): void { $httpClient = $frameworkConfig->httpClient(); $httpClient->defaultOptions([ 'extra' => ['curl' => ['foo' => 'bar']] ]); $httpClient->scopedClient('some_client') ->baseUri('https://some.uri') ->header('Accept', 'application/json') ->extra(['curl' => ['foo' => 'bar']]); } ``` Commits ------- 6c898944d6 [FrameworkBundle] Add `extra` attribute for HttpClient Configuration
… Configuration (voodooism) This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [FrameworkBundle] Add `extra` attribute for HttpClient Configuration | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT | Doc PR | coming soon...<!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help reviewers and should be a good start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the latest branch. - For new features, provide some code snippets to help understand usage. - Changelog entry sh - ould follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry - Never break backward compatibility (see https://symfony.com/bc). --> I want to configure HttpClient once in configure file and forget about the configuration when doing a request or injection. In my particular case, I want to pass certificates to the client as raw values using special curlopts. Here symfony/symfony#48775 proposed the best way to do it - using `extra` attribute in configuration. It's going to look like so ```php return static function (FrameworkConfig $frameworkConfig): void { $httpClient = $frameworkConfig->httpClient(); $httpClient->defaultOptions([ 'extra' => ['curl' => ['foo' => 'bar']] ]); $httpClient->scopedClient('some_client') ->baseUri('https://some.uri') ->header('Accept', 'application/json') ->extra(['curl' => ['foo' => 'bar']]); } ``` Commits ------- 6c898944d6 [FrameworkBundle] Add `extra` attribute for HttpClient Configuration
It would be good to have an opportunity to pass raw data instead of path in HTTP-client configuration, like so: