mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-13 17:55:30 +00:00
Add support for specifying a list of cookies to be passed in the HTTP request. Fixes bug #518722.
Original commit message from CVS: Patch by: Wouter Cloetens <wouter at mind dot be> * ext/soup/gstsouphttpsrc.c: (gst_soup_http_src_class_init), (gst_soup_http_src_init), (gst_soup_http_src_dispose), (gst_soup_http_src_set_property), (gst_soup_http_src_get_property), (gst_soup_http_src_create): * ext/soup/gstsouphttpsrc.h: * tests/check/elements/souphttpsrc.c: (run_test), (GST_START_TEST), (souphttpsrc_suite): Add support for specifying a list of cookies to be passed in the HTTP request. Fixes bug #518722.
This commit is contained in:
parent
bf2fdcbb29
commit
c99b95d8cb
4 changed files with 40 additions and 1 deletions
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit a574e6214b06fcbdfc00e952e2f3edc06997ee93
|
Subproject commit 1c5138efc5679d9eaee66c84dcfabdec5b727493
|
|
@ -117,6 +117,7 @@ enum
|
||||||
PROP_USER_AGENT,
|
PROP_USER_AGENT,
|
||||||
PROP_AUTOMATIC_REDIRECT,
|
PROP_AUTOMATIC_REDIRECT,
|
||||||
PROP_PROXY,
|
PROP_PROXY,
|
||||||
|
PROP_COOKIES,
|
||||||
PROP_IRADIO_MODE,
|
PROP_IRADIO_MODE,
|
||||||
PROP_IRADIO_NAME,
|
PROP_IRADIO_NAME,
|
||||||
PROP_IRADIO_GENRE,
|
PROP_IRADIO_GENRE,
|
||||||
|
@ -240,6 +241,9 @@ gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
|
||||||
PROP_PROXY,
|
PROP_PROXY,
|
||||||
g_param_spec_string ("proxy", "Proxy",
|
g_param_spec_string ("proxy", "Proxy",
|
||||||
"HTTP proxy server URI", "", G_PARAM_READWRITE));
|
"HTTP proxy server URI", "", G_PARAM_READWRITE));
|
||||||
|
g_object_class_install_property (gobject_class,
|
||||||
|
PROP_COOKIES, g_param_spec_boxed ("cookies", "Cookies",
|
||||||
|
"HTTP request cookies", G_TYPE_STRV, G_PARAM_READWRITE));
|
||||||
|
|
||||||
/* icecast stuff */
|
/* icecast stuff */
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
|
@ -291,6 +295,7 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src, GstSoupHTTPSrcClass * g_class)
|
||||||
src->location = NULL;
|
src->location = NULL;
|
||||||
src->automatic_redirect = TRUE;
|
src->automatic_redirect = TRUE;
|
||||||
src->user_agent = g_strdup (DEFAULT_USER_AGENT);
|
src->user_agent = g_strdup (DEFAULT_USER_AGENT);
|
||||||
|
src->cookies = NULL;
|
||||||
src->icy_caps = NULL;
|
src->icy_caps = NULL;
|
||||||
src->iradio_mode = FALSE;
|
src->iradio_mode = FALSE;
|
||||||
src->iradio_name = NULL;
|
src->iradio_name = NULL;
|
||||||
|
@ -328,6 +333,7 @@ gst_soup_http_src_dispose (GObject * gobject)
|
||||||
soup_uri_free (src->proxy);
|
soup_uri_free (src->proxy);
|
||||||
src->proxy = NULL;
|
src->proxy = NULL;
|
||||||
}
|
}
|
||||||
|
g_strfreev (src->cookies);
|
||||||
g_free (src->iradio_name);
|
g_free (src->iradio_name);
|
||||||
src->iradio_name = NULL;
|
src->iradio_name = NULL;
|
||||||
g_free (src->iradio_genre);
|
g_free (src->iradio_genre);
|
||||||
|
@ -397,6 +403,10 @@ gst_soup_http_src_set_property (GObject * object, guint prop_id,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PROP_COOKIES:
|
||||||
|
g_strfreev (src->cookies);
|
||||||
|
src->cookies = g_strdupv (g_value_get_boxed (value));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
return;
|
return;
|
||||||
|
@ -428,6 +438,9 @@ gst_soup_http_src_get_property (GObject * object, guint prop_id,
|
||||||
free (proxy);
|
free (proxy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PROP_COOKIES:
|
||||||
|
g_value_set_boxed (value, g_strdupv (src->cookies));
|
||||||
|
break;
|
||||||
case PROP_IRADIO_MODE:
|
case PROP_IRADIO_MODE:
|
||||||
g_value_set_boolean (value, src->iradio_mode);
|
g_value_set_boolean (value, src->iradio_mode);
|
||||||
break;
|
break;
|
||||||
|
@ -860,6 +873,14 @@ gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
||||||
soup_message_headers_append (src->msg->request_headers, "icy-metadata",
|
soup_message_headers_append (src->msg->request_headers, "icy-metadata",
|
||||||
"1");
|
"1");
|
||||||
}
|
}
|
||||||
|
if (src->cookies) {
|
||||||
|
gchar **cookie;
|
||||||
|
|
||||||
|
for (cookie = src->cookies; *cookie != NULL; cookie++) {
|
||||||
|
soup_message_headers_append (src->msg->request_headers, "Cookie",
|
||||||
|
*cookie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (src->msg, "got_headers",
|
g_signal_connect (src->msg, "got_headers",
|
||||||
G_CALLBACK (gst_soup_http_src_got_headers_cb), src);
|
G_CALLBACK (gst_soup_http_src_got_headers_cb), src);
|
||||||
|
|
|
@ -51,6 +51,7 @@ struct _GstSoupHTTPSrc {
|
||||||
gchar *user_agent; /* User-Agent HTTP header. */
|
gchar *user_agent; /* User-Agent HTTP header. */
|
||||||
gboolean automatic_redirect; /* Follow redirects. */
|
gboolean automatic_redirect; /* Follow redirects. */
|
||||||
SoupURI *proxy; /* HTTP proxy URI. */
|
SoupURI *proxy; /* HTTP proxy URI. */
|
||||||
|
gchar **cookies; /* HTTP request cookies. */
|
||||||
GMainContext *context; /* I/O context. */
|
GMainContext *context; /* I/O context. */
|
||||||
GMainLoop *loop; /* Event loop. */
|
GMainLoop *loop; /* Event loop. */
|
||||||
SoupSession *session; /* Async context. */
|
SoupSession *session; /* Async context. */
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
static int http_port = 0, https_port = 0;
|
static int http_port = 0, https_port = 0;
|
||||||
gboolean redirect = TRUE;
|
gboolean redirect = TRUE;
|
||||||
|
static const char **cookies = NULL;
|
||||||
|
|
||||||
static int run_server (int *http_port, int *https_port);
|
static int run_server (int *http_port, int *https_port);
|
||||||
|
|
||||||
|
@ -80,6 +81,8 @@ run_test (const char *format, ...)
|
||||||
g_free (url);
|
g_free (url);
|
||||||
|
|
||||||
g_object_set (src, "automatic-redirect", redirect, NULL);
|
g_object_set (src, "automatic-redirect", redirect, NULL);
|
||||||
|
if (cookies != NULL)
|
||||||
|
g_object_set (src, "cookies", cookies, NULL);
|
||||||
g_object_set (sink, "signal-handoffs", TRUE, NULL);
|
g_object_set (sink, "signal-handoffs", TRUE, NULL);
|
||||||
g_signal_connect (sink, "preroll-handoff", G_CALLBACK (handoff_cb), &buf);
|
g_signal_connect (sink, "preroll-handoff", G_CALLBACK (handoff_cb), &buf);
|
||||||
|
|
||||||
|
@ -185,6 +188,19 @@ GST_START_TEST (test_https)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_cookies)
|
||||||
|
{
|
||||||
|
static const char *biscotti[] = { "delacre=yummie", "koekje=lu", NULL };
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
cookies = biscotti;
|
||||||
|
rc = run_test ("http://127.0.0.1:%d/", http_port);
|
||||||
|
cookies = NULL;
|
||||||
|
fail_unless (rc == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_icy_stream)
|
GST_START_TEST (test_icy_stream)
|
||||||
{
|
{
|
||||||
GstElement *pipe, *src, *sink;
|
GstElement *pipe, *src, *sink;
|
||||||
|
@ -276,6 +292,7 @@ souphttpsrc_suite (void)
|
||||||
tcase_add_test (tc_chain, test_redirect_no);
|
tcase_add_test (tc_chain, test_redirect_no);
|
||||||
tcase_add_test (tc_chain, test_not_found);
|
tcase_add_test (tc_chain, test_not_found);
|
||||||
tcase_add_test (tc_chain, test_forbidden);
|
tcase_add_test (tc_chain, test_forbidden);
|
||||||
|
tcase_add_test (tc_chain, test_cookies);
|
||||||
tcase_add_test (tc_chain, test_icy_stream);
|
tcase_add_test (tc_chain, test_icy_stream);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue