From f66dd14298ef44de4fcc3b6f5a4f8e6cece39b7f Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 3 Nov 2023 15:38:03 +0100 Subject: [PATCH] Disable the "Copy as cURL" button when the debug info are disabled Some versions of curl have a bug that prevents collecting the debug info. This is reported by writing an explanation message in the debug buffer. When this is detecting, the "Copy as cURL" button is now skipped (like for other unsupported cases) instead of copying a broken command. --- .../HttpClient/DataCollector/HttpClientDataCollector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php index 68101fc2e9174..dbb9c269a085c 100644 --- a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php +++ b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php @@ -230,6 +230,11 @@ private function getCurlCommand(array $trace): ?string break; } + if (str_starts_with('Due to a bug in curl ', $line)) { + // When the curl client disables debug info due to a curl bug, we cannot build the command. + return null; + } + if ('' === $line || preg_match('/^[*<]|(Host: )/', $line)) { continue; }