souphttpsrc: retry request on early termination from the server

Fix a regression introduced by commit 183695c61a (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
This commit is contained in:
Arnaud Vrac 2017-01-19 11:08:11 +01:00 committed by Sebastian Dröge
parent a8eb0515f1
commit 03db374144

View file

@ -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); GST_LOG_OBJECT (src, "Running request for method: %s", method);
/* Update the position if we are retrying */ /* 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, gst_soup_http_src_add_range_header (src, src->request_position,
src->stop_position); src->stop_position);
} }
@ -1637,7 +1637,8 @@ gst_soup_http_src_read_buffer (GstSoupHTTPSrc * src, GstBuffer ** outbuf)
} }
} else { } else {
gst_buffer_unref (*outbuf); 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 */ /* Maybe the server disconnected, retry */
ret = GST_FLOW_CUSTOM_ERROR; ret = GST_FLOW_CUSTOM_ERROR;
} else { } else {