[libsoup] soup_header_parse_param_list: return empty GHashTable instead of NULL



commit c4ff1663520f2167d274ac04cad7a88e9ba5902c
Author: Dan Winship <danw gnome org>
Date:   Mon Oct 29 08:05:01 2012 -0400

    soup_header_parse_param_list: return empty GHashTable instead of NULL
    
    Special-casing the "no parameters" case here complicates other code
    (eg, currently it causes warnings in SoupCache if you get an empty
    Cache-Control header).

 libsoup/soup-headers.c |    5 +----
 tests/sniffing-test.c  |    7 +------
 2 files changed, 2 insertions(+), 10 deletions(-)
---
diff --git a/libsoup/soup-headers.c b/libsoup/soup-headers.c
index ffa1e77..9c4c808 100644
--- a/libsoup/soup-headers.c
+++ b/libsoup/soup-headers.c
@@ -702,14 +702,11 @@ parse_param_list (const char *header, char delim)
 	char *item, *eq, *name_end, *value;
 	gboolean override;
 
-	list = parse_list (header, delim);
-	if (!list)
-		return NULL;
-
 	params = g_hash_table_new_full (soup_str_case_hash, 
 					soup_str_case_equal,
 					g_free, NULL);
 
+	list = parse_list (header, delim);
 	for (iter = list; iter; iter = iter->next) {
 		item = iter->data;
 		override = FALSE;
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index dd4eb4a..0b5fe19 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -350,18 +350,13 @@ sniffing_content_sniffed (SoupMessage *msg, const char *content_type,
 	GList *keys;
 	GList *iter;
 
-	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);
 
+		g_string_append (full_header, "; ");
 		soup_header_g_string_append_param (full_header,
 						   (const gchar*) iter->data,
 						   value);



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