From 64f10c268ccb4213a3d1a18c18df1a350f163b2f Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 12 Feb 2022 08:13:28 +0100 Subject: ui: Declare more HTTP errors as “temporary” MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should improve the situation with unreliable HTTP proxies. See #725. --- src/ui.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui.c b/src/ui.c index 1ab54ae..204179c 100644 --- a/src/ui.c +++ b/src/ui.c @@ -171,6 +171,27 @@ int progressCb (void * const data, double dltotal, double dlnow, } } +/* Error codes from libcurl, which may be temporary and should be retried. + */ +static bool temporaryCurlError (const CURLcode code) { + switch (code) { + case CURLE_COULDNT_RESOLVE_PROXY: + case CURLE_COULDNT_RESOLVE_HOST: + case CURLE_COULDNT_CONNECT: + case CURLE_WEIRD_SERVER_REPLY: + case CURLE_READ_ERROR: + case CURLE_OPERATION_TIMEDOUT: + case CURLE_SSL_CONNECT_ERROR: + case CURLE_GOT_NOTHING: + case CURLE_SEND_ERROR: + case CURLE_RECV_ERROR: + return true; + + default: + return false; + } +} + #define setAndCheck(k,v) \ httpret = curl_easy_setopt (http, k, v); \ assert (httpret == CURLE_OK); @@ -248,7 +269,7 @@ static CURLcode BarPianoHttpRequest (CURL * const http, do { httpret = curl_easy_perform (http); ++retry; - if (httpret == CURLE_OPERATION_TIMEDOUT) { + if (temporaryCurlError (httpret)) { free (buffer.data); buffer.data = NULL; buffer.pos = 0; -- cgit v1.2.3