[rhythmbox] podcast: restart downloads from the start on HTTP 416 errors
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] podcast: restart downloads from the start on HTTP 416 errors
- Date: Tue, 22 Dec 2020 22:39:59 +0000 (UTC)
commit 24ce14f509edfb2fa6c969626153b8be8fce5c24
Author: Jonathan Matthew <jonathan d14n org>
Date: Wed Dec 23 08:37:23 2020 +1000
podcast: restart downloads from the start on HTTP 416 errors
If we get a Requested Range Not Satisfiable response, we can't
resume a partial download, so we have to retry from the start.
Some podcast hosts do this despite advertising support for range
requests.
podcast/rb-podcast-manager.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/podcast/rb-podcast-manager.c b/podcast/rb-podcast-manager.c
index 5b689b38b..76c2e0508 100644
--- a/podcast/rb-podcast-manager.c
+++ b/podcast/rb-podcast-manager.c
@@ -1970,6 +1970,7 @@ download_task (GTask *task, gpointer source_object, gpointer task_data, GCancell
gboolean retry;
gboolean eof;
goffset start, end, total;
+ gboolean range_request;
int retries;
GValue val = {0,};
char *dl_uri;
@@ -1982,6 +1983,7 @@ download_task (GTask *task, gpointer source_object, gpointer task_data, GCancell
*/
retries = 5;
remote_size = 0;
+ range_request = TRUE;
while (retries-- > 0) {
if (download->in_stream != NULL) {
g_input_stream_close (download->in_stream, NULL, NULL);
@@ -2113,6 +2115,12 @@ download_task (GTask *task, gpointer source_object, gpointer task_data, GCancell
soup_message_headers_set_range (download->request->request_headers, downloaded, -1);
download->in_stream = soup_session_send (pd->priv->soup_session, download->request,
download->cancel, &error);
if (error == NULL && !SOUP_STATUS_IS_SUCCESSFUL (download->request->status_code)) {
+ if (download->request->status_code == SOUP_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE) {
+ rb_debug ("got requested range not satisfiable, disabling resume and
retrying");
+ range_request = FALSE;
+ downloaded = 0;
+ continue;
+ }
error = g_error_new (SOUP_HTTP_ERROR, download->request->status_code, "%s",
download->request->reason_phrase);
}
@@ -2139,6 +2147,7 @@ download_task (GTask *task, gpointer source_object, gpointer task_data, GCancell
remote_size = total;
rb_debug ("resuming download at offset %ld, %ld bytes left", start, total);
} else {
+ range_request = FALSE;
downloaded = 0;
remote_size = soup_message_headers_get_content_length
(download->request->response_headers);
rb_debug ("server didn't honour range request, starting again, total %ld",
remote_size);
@@ -2215,7 +2224,11 @@ download_task (GTask *task, gpointer source_object, gpointer task_data, GCancell
rb_debug ("full file downloaded");
break;
}
- rb_debug ("haven't got the whole file yet, retrying");
+ if (range_request == FALSE) {
+ rb_debug ("range request not supported, restarting");
+ downloaded = 0;
+ } else
+ rb_debug ("haven't got the whole file yet, retrying at %ld", downloaded);
} else if (retry == FALSE) {
rb_debug ("not retrying");
break;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]