Skip to content

[HttpClient] Providing additional options to CurlHttpClient section #14195

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

Merged
merged 1 commit into from
Sep 12, 2020

Conversation

pizzaminded
Copy link
Contributor

Documentation for symfony/symfony#38026 PR.

@javiereguiluz javiereguiluz added the Waiting Code Merge Docs for features pending to be merged label Sep 8, 2020
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Sep 10, 2020
…to CurlHttpClient (pizzaminded)

This PR was squashed before being merged into the 5.2-dev branch.

Discussion
----------

[HttpClient] Allow to provide additional curl options  to CurlHttpClient

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #37798
| License       | MIT
| Doc PR        | symfony/symfony-docs#14195

~~**Tagging as a draft because:**~~
- ~~there is no Doc PR Ready yet~~
- probably there are better test cases required here.

This PR introduces an option to override default curl options defined in `CurlHttpClient`.  To override them, there is a special place in `$options` provided:

````php
$response = $httpClient->request('GET', 'http://your.url.here', [
            'extra' => [
                'curl' => [
                    CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V4,
                ]
            ]
        ]);
````

This feature is available only in `CurlHttpClient` and would be ignored in another clients.

Commits
-------

89329bd [HttpClient] Allow to provide additional curl options  to CurlHttpClient
@OskarStark OskarStark removed the Waiting Code Merge Docs for features pending to be merged label Sep 10, 2020
@OskarStark OskarStark added this to the 5.2 milestone Sep 10, 2020
http_client.rst Outdated
@@ -728,6 +728,39 @@ When using this component in a full-stack Symfony application, this behavior is
not configurable and cURL will be used automatically if the cURL PHP extension
is installed and enabled. Otherwise, the native PHP streams will be used.

Providing additional options to CurlHttpClient
Copy link
Contributor

Choose a reason for hiding this comment

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

Additional Options ...

Uppercase letters. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

http_client.rst Outdated
Providing additional options to CurlHttpClient
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It is possible to provide additional cURL options to CurlHttpClient. PHP exposes
Copy link
Contributor

Choose a reason for hiding this comment

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

CurlHttpClient in backticks please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

http_client.rst Outdated

It is possible to provide additional cURL options to CurlHttpClient. PHP exposes
a lot of `cURL options`_ that can be passed to ``curl_setopt`` function, but only some
of them are used in CurlHttpClient in favor of bigger component portability.
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

http_client.rst Outdated
// ...
'extra' => [
'curl' => [
\CURLOPT_IPRESOLVE => \CURL_IPRESOLVE_V6
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we can remove the leading slashes to keep the example easier to read

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed.

@javiereguiluz
Copy link
Member

Mikolaj, thanks and congrats on your first Symfony Docs contribution!

It was a fantastic first-time contribution, but we made some minor rewords to make the new contents more similar to the existing contents (but we kept most of your original contribution).

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