Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpClient] Require cURL > 7.37.0 #41662

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

Closed
sebaherrera opened this issue Jun 10, 2021 · 5 comments
Closed

[HttpClient] Require cURL > 7.37.0 #41662

sebaherrera opened this issue Jun 10, 2021 · 5 comments

Comments

@sebaherrera
Copy link

sebaherrera commented Jun 10, 2021

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":{}}

@nicolas-grekas
Copy link
Member

Instead we should skip using the constant when it's not defined.
Would you mind sending a PR?

@sebaherrera
Copy link
Author

sebaherrera commented Jun 10, 2021

Hi, thanks for your answer. I really tried, but not sure where to fix it, since the only line that sets $curlopts[\CURLOPT_HEADEROPT] is https://github.com/symfony/http-client/blob/c7fd9dbab745ab73ec9745f0e745b64a0b297429/CurlHttpClient.php#L176.

Also found that CURLOPT_HEADEROPT is defined.

PHP Version: 7.4.19
cURL Version: 7.29.0

It may be related to: #39889

@nicolas-grekas
Copy link
Member

Should be fixed by #41674.
Can you please confirm?

@sebaherrera
Copy link
Author

It's still not working, and throws the same exception. I think the issue is that CURLOPT_HEADEROPT is defined, but not in the state checked by lines 313-318.

@nicolas-grekas
Copy link
Member

Thanks for the insights.

nicolas-grekas added a commit that referenced this issue Jun 12, 2021
This PR was merged into the 5.2 branch.

Discussion
----------

[HttpClient] fix compat with cURL <= 7.37

| Q             | A
| ------------- | ---
| Branch?       | 5.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #41662
| License       | MIT
| Doc PR        | -

Commits
-------

d8adf51 [HttpClient] fix compat with cURL <= 7.37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants