diff options
author | Seungha Yang <sh.yang@lge.com> | 2017-02-10 20:50:17 +0900 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-02-22 16:20:59 +0200 |
commit | eaf4ccff51d0414f73792b4a7e484dfaf77785f8 (patch) | |
tree | ddab96c5b227e14b6b4170a50120b27fbf037fcb /ext | |
parent | 38af12081e90cb9b7124b911d4efa2a6e5dc66b6 (diff) | |
download | gstreamer-plugins-good-eaf4ccff51d0414f73792b4a7e484dfaf77785f8.tar.gz |
souphttpsrc: Extract redirection uri on libsoup's restarted callback
Let libsoup handle redirection automatically.
And then, to figure out redirection uri, extract it on "restarted"
callback which will be fired before soup_session_send() is returned.
https://bugzilla.gnome.org/show_bug.cgi?id=778428
Diffstat (limited to 'ext')
-rw-r--r-- | ext/soup/gstsouphttpsrc.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index f78a07279..57e5608c2 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -1037,21 +1037,6 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg) src->proxy_id && src->proxy_pw) return; - if (src->automatic_redirect && - soup_session_would_redirect (src->session, msg) && - soup_session_redirect_message (src->session, msg)) { - src->redirection_uri = - soup_uri_to_string (soup_message_get_uri (msg), FALSE); - src->redirection_permanent = - (msg->status_code == SOUP_STATUS_MOVED_PERMANENTLY); - GST_DEBUG_OBJECT (src, "%u redirect to \"%s\" (permanent %d)", - msg->status_code, src->redirection_uri, src->redirection_permanent); - - /* force a retry with the updated message */ - src->ret = GST_FLOW_CUSTOM_ERROR; - return; - } - if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) { /* force an error */ gst_soup_http_src_parse_status (msg, src); @@ -1393,6 +1378,19 @@ gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src) } } +static void +gst_soup_http_src_restarted_cb (SoupMessage * msg, GstSoupHTTPSrc * src) +{ + if (soup_session_would_redirect (src->session, msg)) { + src->redirection_uri = + soup_uri_to_string (soup_message_get_uri (msg), FALSE); + src->redirection_permanent = + (msg->status_code == SOUP_STATUS_MOVED_PERMANENTLY); + GST_DEBUG_OBJECT (src, "%u redirect to \"%s\" (permanent %d)", + msg->status_code, src->redirection_uri, src->redirection_permanent); + } +} + static gboolean gst_soup_http_src_build_message (GstSoupHTTPSrc * src, const gchar * method) { @@ -1422,7 +1420,13 @@ gst_soup_http_src_build_message (GstSoupHTTPSrc * src, const gchar * method) } soup_message_set_flags (src->msg, SOUP_MESSAGE_OVERWRITE_CHUNKS | - SOUP_MESSAGE_NO_REDIRECT); + (src->automatic_redirect ? 0 : SOUP_MESSAGE_NO_REDIRECT)); + + if (src->automatic_redirect) { + g_signal_connect (src->msg, "restarted", + G_CALLBACK (gst_soup_http_src_restarted_cb), src); + } + gst_soup_http_src_add_range_header (src, src->request_position, src->stop_position); |