Description
Symfony version(s) affected: 5.2.10
Description
Hi. HttpClient throws when cURL version < 7.37.0, which introduced CURLOPT_HEADEROPT. It's a rare issue because compatible versions are available since PHP 7.0.7 (see https://www.php.net/manual/es/function.curl-setopt.php), but there are some hosting companies that doesn't have both upgrades aligned correctly.
How to reproduce
Make an HttpClient request as the "Basic Usage" example on documentation using a server with cURL < 7.37.0.
Possible Solution
Fix requirements on composer.json or make a fallback to NativeHttpClient, which works right on such cases.
Additional context
Log example:
{"message":"Uncaught PHP Exception Twig\Error\RuntimeError: "An exception has been thrown during the rendering of a template ("Curl option "CURLOPT_HEADEROPT" is not supported.")." at /home/c1930506/public_html/nueva-tienda/templates/categorias.html.twig line 1","context":{"exception":{"class":"Twig\Error\RuntimeError","message":"An exception has been thrown during the rendering of a template ("Curl option "CURLOPT_HEADEROPT" is not supported.").","code":0,"file":"/home/c1930506/public_html/nueva-tienda/templates/categorias.html.twig:1","previous":{"class":"Symfony\Component\HttpClient\Exception\TransportException","message":"Curl option "CURLOPT_HEADEROPT" is not supported.","code":0,"file":"/home/c1930506/public_html/nueva-tienda/vendor/symfony/http-client/CurlHttpClient.php:316"}}},"level":500,"level_name":"CRITICAL","channel":"request","datetime":"2021-06-10T16:09:26.076139-03:00","extra":{}}