From 03db374144e7f62cefa5190548519692990ea8bc Mon Sep 17 00:00:00 2001 From: Arnaud Vrac Date: Thu, 19 Jan 2017 11:08:11 +0100 Subject: [PATCH] souphttpsrc: retry request on early termination from the server Fix a regression introduced by commit 183695c61a54f1 (refactor to use Soup's sync API). The code previously attempted to reconnect when the server closed the connection early, for example when the stream was put in pause for some time. Reintroduce this feature by checking if EOS is received before the expected content size is downloaded. In this case, do the request starting at the previous read position. https://bugzilla.gnome.org/show_bug.cgi?id=776720 --- ext/soup/gstsouphttpsrc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 73f9e1c55d..78ca199ef3 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -1467,7 +1467,7 @@ gst_soup_http_src_do_request (GstSoupHTTPSrc * src, const gchar * method) GST_LOG_OBJECT (src, "Running request for method: %s", method); /* Update the position if we are retrying */ - if (src->msg && (src->request_position != src->read_position)) { + if (src->msg && src->request_position > 0) { gst_soup_http_src_add_range_header (src, src->request_position, src->stop_position); } @@ -1637,7 +1637,8 @@ gst_soup_http_src_read_buffer (GstSoupHTTPSrc * src, GstBuffer ** outbuf) } } else { gst_buffer_unref (*outbuf); - if (read_bytes < 0) { + if (read_bytes < 0 || + (src->have_size && src->read_position < src->content_size)) { /* Maybe the server disconnected, retry */ ret = GST_FLOW_CUSTOM_ERROR; } else {