diff options
author | Arnaud Vrac <avrac@freebox.fr> | 2017-01-19 11:05:00 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-01-23 12:54:17 +0200 |
commit | c4cf67cfe5f7b03d38d5657c8fa9b8aca19ba400 (patch) | |
tree | 502e5844af1c652bfd4bfc865031d1d08d815c88 /ext | |
parent | 24b2422bf3f5a2b2b05fe323bf0993256b03b6ff (diff) |
souphttpsrc: properly check that seek range was respected
This check must be done only when we are sure the request was
successfully sent. soup_session_send() might fail without setting the
status code. In this case status code is 0 so we would only catch the
error after the seek range check. In this case we would report an error
saying that the seek range was not respected, instead of reporting the
underlying error that triggered the soup_session_send() failure.
https://bugzilla.gnome.org/attachment.cgi?bugid=777222
Diffstat (limited to 'ext')
-rw-r--r-- | ext/soup/gstsouphttpsrc.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index a7b1877a2..c4f70c633 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -1024,7 +1024,6 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg) const char *value; GstTagList *tag_list; GstBaseSrc *basesrc; - GstFlowReturn ret; guint64 newsize; GHashTable *params = NULL; GstEvent *http_headers_event; @@ -1239,23 +1238,7 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg) } /* Handle HTTP errors. */ - ret = gst_soup_http_src_parse_status (msg, src); - - /* Check if Range header was respected. */ - if (ret == GST_FLOW_CUSTOM_ERROR && - src->read_position && msg->status_code != SOUP_STATUS_PARTIAL_CONTENT) { - src->seekable = FALSE; - GST_ELEMENT_ERROR_WITH_DETAILS (src, RESOURCE, SEEK, - (_("Server does not support seeking.")), - ("Server does not accept Range HTTP header, URL: %s, Redirect to: %s", - src->location, GST_STR_NULL (src->redirection_uri)), - ("http-status-code", G_TYPE_UINT, msg->status_code, - "http-redirection-uri", G_TYPE_STRING, - GST_STR_NULL (src->redirection_uri), NULL)); - ret = GST_FLOW_ERROR; - } - - return ret; + return gst_soup_http_src_parse_status (msg, src); } static GstBuffer * @@ -1463,6 +1446,8 @@ gst_soup_http_src_send_message (GstSoupHTTPSrc * src) static GstFlowReturn gst_soup_http_src_do_request (GstSoupHTTPSrc * src, const gchar * method) { + GstFlowReturn ret; + if (src->max_retries != -1 && src->retry_count > src->max_retries) { GST_DEBUG_OBJECT (src, "Max retries reached"); return GST_FLOW_ERROR; @@ -1492,7 +1477,23 @@ gst_soup_http_src_do_request (GstSoupHTTPSrc * src, const gchar * method) return GST_FLOW_FLUSHING; } - return gst_soup_http_src_send_message (src); + ret = gst_soup_http_src_send_message (src); + + /* Check if Range header was respected. */ + if (ret == GST_FLOW_OK && src->request_position > 0 && + src->msg->status_code != SOUP_STATUS_PARTIAL_CONTENT) { + src->seekable = FALSE; + GST_ELEMENT_ERROR_WITH_DETAILS (src, RESOURCE, SEEK, + (_("Server does not support seeking.")), + ("Server does not accept Range HTTP header, URL: %s, Redirect to: %s", + src->location, GST_STR_NULL (src->redirection_uri)), + ("http-status-code", G_TYPE_UINT, src->msg->status_code, + "http-redirection-uri", G_TYPE_STRING, + GST_STR_NULL (src->redirection_uri), NULL)); + ret = GST_FLOW_ERROR; + } + + return ret; } /* |