@@ -728,6 +728,39 @@ When using this component in a full-stack Symfony application, this behavior is
728
728
not configurable and cURL will be used automatically if the cURL PHP extension
729
729
is installed and enabled. Otherwise, the native PHP streams will be used.
730
730
731
+ Providing Additional Options to CurlHttpClient
732
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
733
+
734
+ It is possible to provide additional cURL options to ``CurlHttpClient ``. PHP exposes
735
+ a lot of `cURL options `_ that can be passed to ``curl_setopt `` function, but only some
736
+ of them are used in ``CurlHttpClient `` in favor of bigger component portability.
737
+
738
+ To provide cURL-related parameters to request, add an ``extra.curl `` option in your
739
+ configuration::
740
+
741
+ use Symfony\Component\HttpClient\CurlHttpClient;
742
+
743
+ $client = new CurlHttpClient();
744
+
745
+ $client->request('POST', 'https://...', [
746
+ // ...
747
+ 'extra' => [
748
+ 'curl' => [
749
+ CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V6
750
+ ]
751
+ ]
752
+ ]);
753
+
754
+
755
+ This option is available only when using ``CurlHttpClient ``, other clients will ignore these options.
756
+
757
+ .. note ::
758
+
759
+ Some cURL options are impossible to override due of. e.g Thread Safety or existing options in
760
+ ``$options `` configuration which will set given attributes internally. An exception will be
761
+ thrown while overriding them.
762
+
763
+
731
764
HTTP/2 Support
732
765
~~~~~~~~~~~~~~
733
766
@@ -1391,3 +1424,4 @@ However, using ``MockResponse`` allows simulating chunked responses and timeouts
1391
1424
.. _`Symfony Contracts` : https://github.com/symfony/contracts
1392
1425
.. _`libcurl` : https://curl.haxx.se/libcurl/
1393
1426
.. _`amphp/http-client` : https://packagist.org/packages/amphp/http-client
1427
+ .. _`cURL options` : https://www.php.net/manual/en/function.curl-setopt.php
0 commit comments