Commit c99b95d8 authored by Wouter Cloetens's avatar Wouter Cloetens Committed by Sebastian Dröge
Browse files

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.
parent bf2fdcbb
common @ 1c5138ef
Subproject commit a574e6214b06fcbdfc00e952e2f3edc06997ee93
Subproject commit 1c5138efc5679d9eaee66c84dcfabdec5b727493
......@@ -117,6 +117,7 @@ enum
PROP_USER_AGENT,
PROP_AUTOMATIC_REDIRECT,
PROP_PROXY,
PROP_COOKIES,
PROP_IRADIO_MODE,
PROP_IRADIO_NAME,
PROP_IRADIO_GENRE,
......@@ -240,6 +241,9 @@ gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
PROP_PROXY,
g_param_spec_string ("proxy", "Proxy",
"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 */
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->automatic_redirect = TRUE;
src->user_agent = g_strdup (DEFAULT_USER_AGENT);
src->cookies = NULL;
src->icy_caps = NULL;
src->iradio_mode = FALSE;
src->iradio_name = NULL;
......@@ -328,6 +333,7 @@ gst_soup_http_src_dispose (GObject * gobject)
soup_uri_free (src->proxy);
src->proxy = NULL;
}
g_strfreev (src->cookies);
g_free (src->iradio_name);
src->iradio_name = NULL;
g_free (src->iradio_genre);
......@@ -397,6 +403,10 @@ gst_soup_http_src_set_property (GObject * object, guint prop_id,
}
break;
}
case PROP_COOKIES:
g_strfreev (src->cookies);
src->cookies = g_strdupv (g_value_get_boxed (value));
break;
}
done:
return;
......@@ -428,6 +438,9 @@ gst_soup_http_src_get_property (GObject * object, guint prop_id,
free (proxy);
}
break;
case PROP_COOKIES:
g_value_set_boxed (value, g_strdupv (src->cookies));
break;
case PROP_IRADIO_MODE:
g_value_set_boolean (value, src->iradio_mode);
break;
......@@ -860,6 +873,14 @@ gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
soup_message_headers_append (src->msg->request_headers, "icy-metadata",
"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_CALLBACK (gst_soup_http_src_got_headers_cb), src);
......
......@@ -51,6 +51,7 @@ struct _GstSoupHTTPSrc {
gchar *user_agent; /* User-Agent HTTP header. */
gboolean automatic_redirect; /* Follow redirects. */
SoupURI *proxy; /* HTTP proxy URI. */
gchar **cookies; /* HTTP request cookies. */
GMainContext *context; /* I/O context. */
GMainLoop *loop; /* Event loop. */
SoupSession *session; /* Async context. */
......
......@@ -32,6 +32,7 @@
static int http_port = 0, https_port = 0;
gboolean redirect = TRUE;
static const char **cookies = NULL;
static int run_server (int *http_port, int *https_port);
......@@ -80,6 +81,8 @@ run_test (const char *format, ...)
g_free (url);
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_signal_connect (sink, "preroll-handoff", G_CALLBACK (handoff_cb), &buf);
......@@ -185,6 +188,19 @@ GST_START_TEST (test_https)
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)
{
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_not_found);
tcase_add_test (tc_chain, test_forbidden);
tcase_add_test (tc_chain, test_cookies);
tcase_add_test (tc_chain, test_icy_stream);
return s;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment