diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2017-07-13 14:50:44 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-07-13 14:50:44 +0300 |
commit | d0dfbb04c002bc94fb7d68d420f5276c32b9d991 (patch) | |
tree | a7e4a2ca52cd7a585e720f420bc26e6e50132a2b /ext | |
parent | c0318f3d6070a944986f212c04becef32d18f5f3 (diff) |
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.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/soup/gstsouphttpsrc.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c index 3d588add8..38e7b878c 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); |