Skip to content

Commit

Permalink
curl: Abort dead slow curl connections (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
venkatchimata authored Aug 24, 2021
1 parent 2cb8409 commit bdbda11
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/unum/http/http_curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ int http_get_file(char *url, char *headers, char *file)
curl_easy_setopt(ch, CURLOPT_CONNECTTIMEOUT, REQ_CONNECT_TIMEOUT);
curl_easy_setopt(ch, CURLOPT_TIMEOUT, REQ_FILE_TIMEOUT);
curl_easy_setopt(ch, CURLOPT_HTTPGET, 1);
// If it is less than just 1 byte per second for 60 seconds
// then something wrong with the network. Abort the download
// This will handle a case to timeout the transfer
// on an erred network instead of waiting for full REQ_FILE_TIMEOUT
curl_easy_setopt(ch, CURLOPT_LOW_SPEED_TIME, 60L);
curl_easy_setopt(ch, CURLOPT_LOW_SPEED_LIMIT, 1L);
if(slhdr) {
curl_easy_setopt(ch, CURLOPT_HTTPHEADER, slhdr);
}
Expand Down

0 comments on commit bdbda11

Please sign in to comment.