Merge pull request #1711 from unraid/fix-curl

In http_get_contents, detect and recover from curl error 23
This commit is contained in:
tom mortensen
2024-04-29 09:14:53 -07:00
committed by GitHub
2 changed files with 10 additions and 4 deletions

View File

@@ -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;
}
/**

View File

@@ -29,7 +29,7 @@ proxy_url_1="${proxy}:${port}"
proxy_name_1="Imported from CA"
EOF
fi
mv "${CAProxy}" "${CAProxy}.bak"
mv "${CAProxy}" "${CAProxy}~"
fi
# load proxy environment vars so it is used for plugin updates and the go script