diff --git a/0001-Don-t-prematurely-abort-URL-validity-check-during-se.patch b/0001-Don-t-prematurely-abort-URL-validity-check-during-se.patch new file mode 100644 index 0000000..548f49e --- /dev/null +++ b/0001-Don-t-prematurely-abort-URL-validity-check-during-se.patch @@ -0,0 +1,55 @@ +From d3085b7d1492766f5d7bb5de210c2b11c2e1ead9 Mon Sep 17 00:00:00 2001 +From: Matthias Klumpp +Date: Sun, 18 Feb 2024 06:50:02 +0100 +Subject: [PATCH] Don't prematurely abort URL validity check during semi-large + redirects + +During some redirects we were already downloading enough data to warrant +aborting the download, leaving us with 302 as the last status code, +failing the reachable-URL test. + +With this change, we will only start to count downloadable bytes once we +left the redirects, so we will only count downloaded data at our final +destination. + +Resolves: #597 +--- + src/as-curl.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/as-curl.c b/src/as-curl.c +index 30e492a0..b860b36a 100644 +--- a/src/as-curl.c ++++ b/src/as-curl.c +@@ -110,6 +110,7 @@ as_curl_download_write_bytearray_cb (char *ptr, size_t size, size_t nmemb, void + GByteArray *buf = (GByteArray *) udata; + gsize realsize = size * nmemb; + g_byte_array_append (buf, (const guint8 *) ptr, realsize); ++ + return realsize; + } + +@@ -368,11 +369,18 @@ as_curl_progress_check_url_cb (void *clientp, + curl_off_t ulnow) + { + AsCurlPrivate *priv = GET_PRIVATE ((AsCurl *) clientp); ++ glong status_code; ++ ++ /* always continue if we are still being redirected */ ++ curl_easy_getinfo (priv->curl, CURLINFO_RESPONSE_CODE, &status_code); ++ if (status_code == 302) ++ return 0; ++ + priv->bytes_downloaded = dlnow; + +- /* stop after 2kb have been successfully downloaded - it turns out a lot ++ /* stop after 1kb has been successfully downloaded - it turns out a lot + * of downloads fail later, so just checking for the first byte is not enough */ +- if (dlnow >= 2048) ++ if (dlnow >= 1024) + return 1; + return 0; + } +-- +2.43.0 +