[libsoup/content-sniffing] Test that only the last Content-Type header is used



commit 49a7fdb3785b16bd3015e3e2fa4f3fd5916a347a
Author: Gustavo Noronha Silva <gns gnome org>
Date:   Mon Jun 22 15:07:44 2009 -0300

    Test that only the last Content-Type header is used
    
    The content type sniffing spec says that only the last Content-Type
    header should be used.

 tests/sniffing-test.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index 048ba42..14a976f 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -125,6 +125,33 @@ server_callback (SoupServer *server, SoupMessage *msg,
 
 		g_strfreev (components);
 	}
+
+	if (g_str_has_prefix (path, "/multiple_headers/")) {
+		char *base_name = g_path_get_basename (path);
+		char *file_name = g_strdup_printf ("resources/%s", base_name);
+
+		g_file_get_contents (file_name,
+				     &contents, &length,
+				     &error);
+
+		g_free (base_name);
+		g_free (file_name);
+
+		if (error) {
+			g_error ("%s", error->message);
+			g_error_free (error);
+			exit (1);
+		}
+
+		soup_message_set_response (msg, "text/xml",
+					   SOUP_MEMORY_TAKE,
+					   contents,
+					   length);
+
+		soup_message_headers_append (msg->response_headers,
+					     "Content-Type", "text/plain");
+	}
+
 }
 
 static gboolean
@@ -365,6 +392,10 @@ main (int argc, char **argv)
 
 	test_sniffing ("/type/image_png/home.gif", "image/gif");
 
+	/* The spec tells us to only use the last Content-Type header */
+
+	test_sniffing ("/multiple_headers/home.gif", "image/gif");
+
 	soup_uri_free (base_uri);
 
 	test_cleanup ();



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