diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2022-02-12 08:13:28 +0100 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2022-02-12 08:13:28 +0100 |
commit | 64f10c268ccb4213a3d1a18c18df1a350f163b2f (patch) | |
tree | 719a0b90b792ed3280a737f227670afc64ca8f90 | |
parent | 69e495c9ac70c1c635a9ae3ce6d4461f9bbba0d1 (diff) | |
download | pianobar-64f10c268ccb4213a3d1a18c18df1a350f163b2f.tar.gz pianobar-64f10c268ccb4213a3d1a18c18df1a350f163b2f.tar.bz2 pianobar-64f10c268ccb4213a3d1a18c18df1a350f163b2f.zip |
ui: Declare more HTTP errors as “temporary”
This should improve the situation with unreliable HTTP proxies. See #725.
-rw-r--r-- | src/ui.c | 23 |
1 files changed, 22 insertions, 1 deletions
@@ -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; |