souphttpsrc: add redirection to the URI query

This commit is contained in:
Andoni Morales Alastruey 2013-07-13 01:50:56 +02:00
parent 2269ac8f28
commit b9faeab236
2 changed files with 14 additions and 1 deletions

View file

@ -299,6 +299,7 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src)
g_mutex_init (&src->mutex);
g_cond_init (&src->request_finished_cond);
src->location = NULL;
src->redirection_uri = NULL;
src->automatic_redirect = TRUE;
src->user_agent = g_strdup (DEFAULT_USER_AGENT);
src->user_id = NULL;
@ -331,6 +332,9 @@ gst_soup_http_src_finalize (GObject * gobject)
g_mutex_clear (&src->mutex);
g_cond_clear (&src->request_finished_cond);
g_free (src->location);
if (src->redirection_uri) {
g_free (src->redirection_uri);
}
g_free (src->user_agent);
if (src->proxy != NULL) {
soup_uri_free (src->proxy);
@ -744,8 +748,10 @@ gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
return;
if (src->automatic_redirect && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
src->redirection_uri = g_strdup (soup_message_headers_get
(msg->response_headers, "Location"));
GST_DEBUG_OBJECT (src, "%u redirect to \"%s\"", msg->status_code,
soup_message_headers_get_one (msg->response_headers, "Location"));
src->redirection_uri);
return;
}
@ -1460,6 +1466,7 @@ gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query)
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_URI:
gst_query_set_uri (query, src->location);
gst_query_set_uri_redirection (query, src->redirection_uri);
ret = TRUE;
break;
default:
@ -1506,6 +1513,11 @@ gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri,
}
}
if (src->redirection_uri) {
g_free (src->redirection_uri);
src->redirection_uri = NULL;
}
src->location = g_strdup (uri);
return TRUE;

View file

@ -49,6 +49,7 @@ struct _GstSoupHTTPSrc {
GstPushSrc element;
gchar *location; /* Full URI. */
gchar *redirection_uri; /* Full URI after redirections. */
gchar *user_agent; /* User-Agent HTTP header. */
gboolean automatic_redirect; /* Follow redirects. */
SoupURI *proxy; /* HTTP proxy URI. */