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

[FrameworkBundle] Add extra attribute for HttpClient Configuration #48797

Merged

Conversation

voodooism
Copy link
Contributor

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
License MIT
Doc PR coming soon...

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

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']]);
}

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@OskarStark
Copy link
Contributor

Please add some documentation against, thanks

@fabpot fabpot force-pushed the feature/add-extra-curl-supporting-in-config branch from 5192d97 to 6c89894 Compare January 5, 2023 06:56
@fabpot
Copy link
Member

fabpot commented Jan 5, 2023

Thank you @voodooism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants