From d0dfbb04c002bc94fb7d68d420f5276c32b9d991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 13 Jul 2017 14:50:44 +0300 Subject: [PATCH] souphttpsrc: Post an element message with the HTTP headers on the bus too Instead of just sending a sticky event with them downstream. This allows getting the HTTP headers easily in the application, and especially also on errors. --- ext/soup/gstsouphttpsrc.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 3d588add8a..38e7b878c1 100644 --- a/ext/soup/gstsouphttpsrc.c +++ b/ext/soup/gstsouphttpsrc.c @@ -1130,16 +1130,9 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg) return GST_FLOW_OK; } - if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) { - /* force an error */ - return gst_soup_http_src_parse_status (msg, src); - } - - src->got_headers = TRUE; - g_cond_broadcast (&src->have_headers_cond); - http_headers = gst_structure_new_empty ("http-headers"); - gst_structure_set (http_headers, "uri", G_TYPE_STRING, src->location, NULL); + gst_structure_set (http_headers, "uri", G_TYPE_STRING, src->location, + "http-status-code", G_TYPE_UINT, msg->status_code, NULL); if (src->redirection_uri) gst_structure_set (http_headers, "redirection-uri", G_TYPE_STRING, src->redirection_uri, NULL); @@ -1156,6 +1149,19 @@ gst_soup_http_src_got_headers (GstSoupHTTPSrc * src, SoupMessage * msg) headers, NULL); gst_structure_free (headers); + gst_element_post_message (GST_ELEMENT_CAST (src), + gst_message_new_element (GST_OBJECT_CAST (src), + gst_structure_copy (http_headers))); + + if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) { + /* force an error */ + gst_structure_free (http_headers); + return gst_soup_http_src_parse_status (msg, src); + } + + src->got_headers = TRUE; + g_cond_broadcast (&src->have_headers_cond); + http_headers_event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM_STICKY, http_headers); gst_event_replace (&src->http_headers_event, http_headers_event);