summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2010-08-06 10:44:24 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-08-06 10:44:24 +0100
commit640a1ff0e81143fe8bb502ef2f46492d2d5e4f37 (patch)
tree7d59e607c40d54323bb62c61f3396fdde857b434
parentc2c32fe773aacfdcf823e6faf4a2327e6f997760 (diff)
downloadgstreamer-plugins-bad-640a1ff0e81143fe8bb502ef2f46492d2d5e4f37.tar.gz
neonhttpsrc: add "cookies" property
Based on patch by: Sameer Naik https://bugzilla.gnome.org/show_bug.cgi?id=625174
-rw-r--r--ext/neon/gstneonhttpsrc.c32
-rw-r--r--ext/neon/gstneonhttpsrc.h1
-rw-r--r--tests/check/elements/neonhttpsrc.c6
3 files changed, 39 insertions, 0 deletions
diff --git a/ext/neon/gstneonhttpsrc.c b/ext/neon/gstneonhttpsrc.c
index fbe041dc5..0e4f472d6 100644
--- a/ext/neon/gstneonhttpsrc.c
+++ b/ext/neon/gstneonhttpsrc.c
@@ -66,6 +66,7 @@ enum
PROP_LOCATION,
PROP_PROXY,
PROP_USER_AGENT,
+ PROP_COOKIES,
PROP_IRADIO_MODE,
PROP_IRADIO_NAME,
PROP_IRADIO_GENRE,
@@ -173,6 +174,17 @@ gst_neonhttp_src_class_init (GstNeonhttpSrcClass * klass)
"Value of the User-Agent HTTP request header field",
"GStreamer neonhttpsrc", G_PARAM_READWRITE));
+ /**
+ * GstNeonhttpSrc:cookies
+ *
+ * HTTP request cookies
+ *
+ * Since: 0.10.20
+ */
+ g_object_class_install_property (gobject_class, PROP_COOKIES,
+ g_param_spec_boxed ("cookies", "Cookies", "HTTP request cookies",
+ G_TYPE_STRV, G_PARAM_READWRITE));
+
g_object_class_install_property
(gobject_class, PROP_IRADIO_MODE,
g_param_spec_boolean ("iradio-mode", "iradio-mode",
@@ -242,6 +254,7 @@ gst_neonhttp_src_init (GstNeonhttpSrc * src, GstNeonhttpSrcClass * g_class)
src->automatic_redirect = DEFAULT_AUTOMATIC_REDIRECT;
src->accept_self_signed = DEFAULT_ACCEPT_SELF_SIGNED;
+ src->cookies = NULL;
src->session = NULL;
src->request = NULL;
memset (&src->uri, 0, sizeof (src->uri));
@@ -274,6 +287,11 @@ gst_neonhttp_src_dispose (GObject * gobject)
g_free (src->iradio_genre);
g_free (src->iradio_url);
+ if (src->cookies) {
+ g_strfreev (src->cookies);
+ src->cookies = NULL;
+ }
+
if (src->icy_caps) {
gst_caps_unref (src->icy_caps);
src->icy_caps = NULL;
@@ -344,6 +362,11 @@ gst_neonhttp_src_set_property (GObject * object, guint prop_id,
g_free (src->user_agent);
src->user_agent = g_strdup (g_value_get_string (value));
break;
+ case PROP_COOKIES:
+ if (src->cookies)
+ g_strfreev (src->cookies);
+ src->cookies = (gchar **) g_value_dup_boxed (value);
+ break;
case PROP_IRADIO_MODE:
src->iradio_mode = g_value_get_boolean (value);
break;
@@ -406,6 +429,9 @@ gst_neonhttp_src_get_property (GObject * object, guint prop_id,
case PROP_USER_AGENT:
g_value_set_string (value, neonhttpsrc->user_agent);
break;
+ case PROP_COOKIES:
+ g_value_set_boxed (value, neonhttpsrc->cookies);
+ break;
case PROP_IRADIO_MODE:
g_value_set_boolean (value, neonhttpsrc->iradio_mode);
break;
@@ -823,6 +849,7 @@ gst_neonhttp_src_send_request_and_redirect (GstNeonhttpSrc * src,
{
ne_session *session = NULL;
ne_request *request = NULL;
+ gchar **c;
gint res;
gint http_status = 0;
guint request_count = 0;
@@ -849,6 +876,11 @@ gst_neonhttp_src_send_request_and_redirect (GstNeonhttpSrc * src,
ne_add_request_header (request, "User-Agent", src->user_agent);
}
+ for (c = src->cookies; c != NULL && *c != NULL; ++c) {
+ GST_INFO ("Adding header Cookie : %s", *c);
+ ne_add_request_header (request, "Cookies", *c);
+ }
+
if (src->iradio_mode) {
ne_add_request_header (request, "icy-metadata", "1");
}
diff --git a/ext/neon/gstneonhttpsrc.h b/ext/neon/gstneonhttpsrc.h
index f88c964cc..ae10fd3d8 100644
--- a/ext/neon/gstneonhttpsrc.h
+++ b/ext/neon/gstneonhttpsrc.h
@@ -52,6 +52,7 @@ struct _GstNeonhttpSrc {
gchar *query_string;
ne_uri proxy;
gchar *user_agent;
+ gchar **cookies;
guint64 content_size;
diff --git a/tests/check/elements/neonhttpsrc.c b/tests/check/elements/neonhttpsrc.c
index 1a54e5c7f..49e365250 100644
--- a/tests/check/elements/neonhttpsrc.c
+++ b/tests/check/elements/neonhttpsrc.c
@@ -37,6 +37,7 @@ GST_START_TEST (test_first_buffer_has_offset)
GstStateChangeReturn ret;
GstElement *pipe, *src, *sink;
GstBuffer *buf = NULL;
+ gchar **cookies;
pipe = gst_pipeline_new (NULL);
@@ -53,6 +54,11 @@ GST_START_TEST (test_first_buffer_has_offset)
g_object_set (src, "location", "http://gstreamer.freedesktop.org/", NULL);
g_object_set (src, "automatic-redirect", TRUE, NULL);
+ /* set some cookies (shouldn't hurt) */
+ cookies = g_strsplit ("foo=1234,bar=9871615348162523726337x99FB", ",", -1);
+ g_object_set (src, "cookies", cookies, NULL);
+ g_strfreev (cookies);
+
g_object_set (sink, "signal-handoffs", TRUE, NULL);
g_signal_connect (sink, "preroll-handoff", G_CALLBACK (handoff_cb), &buf);