[HttpClient] Never process more than 300 requests at the same time

by @nicolas-grekas

Some issues have been detected in this pull request

Issues that can be fixed by applying a patch

Review the proposed patch then download it to apply it manually or execute the following command from the repository root directory:

curl https://fabbot.io/patch/symfony/symfony/38690/b2325ffde39746dd95dd0fe0cc8e1d25ed6b3a71/cs.diff | patch -p0
diff -ru src/Symfony/Component/HttpClient/CurlHttpClient.php src/Symfony/Component/HttpClient/CurlHttpClient.php
--- src/Symfony/Component/HttpClient/CurlHttpClient.php	2023-03-30 16:36:23.482056320 +0000
+++ src/Symfony/Component/HttpClient/CurlHttpClient.php	2023-03-30 16:36:29.036284609 +0000
@@ -93,7 +93,7 @@
         }
 
         // HTTP/2 push crashes before curl 7.61
-        if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > self::$curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & self::$curlVersion['features'])) {
+        if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073D00 > self::$curlVersion['version_number'] || !(\CURL_VERSION_HTTP2 & self::$curlVersion['features'])) {
             return;
         }
 
@@ -188,7 +188,7 @@
             $this->multi->dnsCache->evictions = [];
             $port = parse_url($authority, \PHP_URL_PORT) ?: ('http:' === $scheme ? 80 : 443);
 
-            if ($resolve && 0x072a00 > self::$curlVersion['version_number']) {
+            if ($resolve && 0x072A00 > self::$curlVersion['version_number']) {
                 // DNS cache removals require curl 7.42 or higher
                 // On lower versions, we have to create a new multi handle
                 curl_multi_close($this->multi->handle);
@@ -333,7 +333,8 @@
 
         if (\is_resource($this->multi->handle) || $this->multi->handle instanceof \CurlMultiHandle) {
             $active = 0;
-            while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
+            while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)) {
+            }
         }
 
         return new ResponseStream(CurlResponse::stream($responses, $timeout));
@@ -357,7 +358,8 @@
             }
 
             $active = 0;
-            while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
+            while (\CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active)) {
+            }
         }
 
         foreach ($this->multi->openHandles as [$ch]) {
@@ -367,7 +369,7 @@
         }
 
         foreach ($this->multi->pendingHandles as [$ch]) {
-            curl_setopt($ch, CURLOPT_VERBOSE, false);
+            curl_setopt($ch, \CURLOPT_VERBOSE, false);
         }
     }
 
@@ -521,7 +523,7 @@
     private function validateExtraCurlOptions(array $options): void
     {
         $curloptsToConfig = [
-            //options used in CurlHttpClient
+            // options used in CurlHttpClient
             \CURLOPT_HTTPAUTH => 'auth_ntlm',
             \CURLOPT_USERPWD => 'auth_ntlm',
             \CURLOPT_RESOLVE => 'resolve',
@@ -551,7 +553,7 @@
             \CURLOPT_CERTINFO => 'capture_peer_cert_chain',
             \CURLOPT_USERAGENT => 'normalized_headers',
             \CURLOPT_REFERER => 'headers',
-            //options used in CurlResponse
+            // options used in CurlResponse
             \CURLOPT_NOPROGRESS => 'on_progress',
             \CURLOPT_PROGRESSFUNCTION => 'on_progress',
         ];

0
Common Typos

0
License Headers

0
Pull Request Contributor Headers

0
File Permissions

0
Merge Commits

0
Exception Messages Formatting

0
Usage of void in test files

0
Use ::class whenever possible

0
Deprecation Messages