[libsoup] Add test that makes sure parameters are preserved



commit c52b4dea26e446d99483bc1f32c7e90f98f048fa
Author: Gustavo Noronha Silva <gustavo noronha collabora co uk>
Date:   Mon Feb 8 11:03:38 2010 -0200

    Add test that makes sure parameters are preserved

 tests/sniffing-test.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index 26ddc16..9aca27b 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -352,8 +352,31 @@ sniffing_content_sniffed (SoupMessage *msg, const char *content_type,
 			  GHashTable *params, gpointer data)
 {
 	char **sniffed_type = (char **)data;
+	GString *full_header;
+	GList *keys;
+	GList *iter;
 
-	*sniffed_type = g_strdup (content_type);
+	if (params == NULL) {
+		*sniffed_type = g_strdup (content_type);
+		return;
+	}
+
+	full_header = g_string_new (content_type);
+	g_string_append (full_header, "; ");
+
+	keys = g_hash_table_get_keys (params);
+	for (iter = keys; iter != NULL; iter = iter->next) {
+		const gchar *value = (const gchar*) g_hash_table_lookup (params, iter->data);
+
+		soup_header_g_string_append_param (full_header,
+						   (const gchar*) iter->data,
+						   value);
+	}
+
+	*sniffed_type = full_header->str;
+
+	g_string_free (full_header, FALSE);
+	g_list_free (keys);
 }
 
 static void
@@ -516,6 +539,9 @@ main (int argc, char **argv)
 
 	test_sniffing ("/multiple_headers/home.gif", "image/gif");
 
+	/* Test that we keep the parameters when sniffing */
+	test_sniffing ("/type/text_html; charset=\"UTF-8\"/test.html", "text/html; charset=\"UTF-8\"");
+
 	/* Test that disabling the sniffer works correctly */
 
 	test_disabled ("/text_or_binary/home.gif");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]