From e6441a8345301738545ac12ff72f7348a66d697c Mon Sep 17 00:00:00 2001 From: ljm42 Date: Sun, 28 Apr 2024 16:12:40 -0700 Subject: [PATCH] in http_get_contents, detect and recover from curl error 23 --- emhttp/plugins/dynamix/include/Wrappers.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/include/Wrappers.php b/emhttp/plugins/dynamix/include/Wrappers.php index 115801216..0963472fa 100644 --- a/emhttp/plugins/dynamix/include/Wrappers.php +++ b/emhttp/plugins/dynamix/include/Wrappers.php @@ -180,16 +180,22 @@ function http_get_contents(string $url, array $opts = [], array &$getinfo = NULL } } $out = curl_exec($ch); - if(isset($getinfo)) { + if (curl_errno($ch) == 23) { + // error 23 detected, try CURLOPT_ENCODING = null + curl_setopt($ch, CURLOPT_ENCODING, null); + $out = curl_exec($ch); + } + if (isset($getinfo)) { $getinfo = curl_getinfo($ch); } - if (curl_errno($ch)) { - $msg = curl_error($ch) . " {$url}"; + if ($errno = curl_errno($ch)) { + $msg = "Curl error $errno: " . (curl_error($ch) ?: curl_strerror($errno)) . ". Requested url: '$url'"; if(isset($getinfo)) { $getinfo['error'] = $msg; } my_logger($msg, "http_get_contents"); } + curl_close($ch); return $out; } /**