mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-23 09:04:15 +00:00
souphttpsrc: Allow non-string fields in the extra-headers property
This commit is contained in:
parent
a9e496d92f
commit
9bf294c310
1 changed files with 47 additions and 10 deletions
|
@ -621,23 +621,26 @@ gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src, guint64 offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_append_extra_headers (GQuark field_id, const GValue * value,
|
_append_extra_header (GQuark field_id, const GValue * value, gpointer user_data)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (user_data);
|
GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (user_data);
|
||||||
const gchar *field_name = g_quark_to_string (field_id);
|
const gchar *field_name = g_quark_to_string (field_id);
|
||||||
const gchar *field_content;
|
gchar *field_content = NULL;
|
||||||
|
|
||||||
if (G_VALUE_TYPE (value) != G_TYPE_STRING) {
|
if (G_VALUE_TYPE (value) == G_TYPE_STRING) {
|
||||||
GST_ERROR_OBJECT (src, "Invalid typed extra-headers field '%s'",
|
field_content = g_value_dup_string (value);
|
||||||
field_name);
|
} else {
|
||||||
return FALSE;
|
GValue dest = { 0, };
|
||||||
|
|
||||||
|
g_value_init (&dest, G_TYPE_STRING);
|
||||||
|
if (g_value_transform (value, &dest)) {
|
||||||
|
field_content = g_value_dup_string (&dest);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
field_content = g_value_get_string (value);
|
|
||||||
if (field_content == NULL) {
|
if (field_content == NULL) {
|
||||||
GST_ERROR_OBJECT (src, "extra-headers field '%s' contains no value",
|
GST_ERROR_OBJECT (src, "extra-headers field '%s' contains no value "
|
||||||
field_name);
|
"or can't be converted to a string", field_name);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,6 +648,40 @@ _append_extra_headers (GQuark field_id, const GValue * value,
|
||||||
field_content);
|
field_content);
|
||||||
soup_message_headers_append (src->msg->request_headers, field_name,
|
soup_message_headers_append (src->msg->request_headers, field_name,
|
||||||
field_content);
|
field_content);
|
||||||
|
|
||||||
|
g_free (field_content);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_append_extra_headers (GQuark field_id, const GValue * value,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
if (G_VALUE_TYPE (value) == GST_TYPE_ARRAY) {
|
||||||
|
guint n = gst_value_array_get_size (value);
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
const GValue *v = gst_value_array_get_value (value, i);
|
||||||
|
|
||||||
|
if (!_append_extra_header (field_id, v, user_data))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
|
||||||
|
guint n = gst_value_list_get_size (value);
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < n; i++) {
|
||||||
|
const GValue *v = gst_value_list_get_value (value, i);
|
||||||
|
|
||||||
|
if (!_append_extra_header (field_id, v, user_data))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return _append_extra_header (field_id, value, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue