Revision: 14656
Author: adrian.chadd
Date: Thu May 13 03:00:15 2010
Log: Add in a check to ensure the parser correctly removes duplicate Content-Length
headers and keeps the correct one.


http://code.google.com/p/lusca-cache/source/detail?r=14656

Modified:
 /branches/LUSCA_HEAD/test-suite/atf/libhttp.c

=======================================
--- /branches/LUSCA_HEAD/test-suite/atf/libhttp.c       Thu May 13 02:41:18 2010
+++ /branches/LUSCA_HEAD/test-suite/atf/libhttp.c       Thu May 13 03:00:15 2010
@@ -62,6 +62,22 @@
        ATF_CHECK_EQ(test_core_parse_header(&hdr, str), ret);
        httpHeaderClean(&hdr);
 }
+
+static void
+libhttp_test_content_length_parser(const char *str, const char *clength)
+{
+       HttpHeader hdr;
+       HttpHeaderEntry *e;
+
+       ATF_CHECK_EQ(test_core_parse_header(&hdr, str), 1);
+
+       /* Verify the content-length header is what it should be */
+       e = httpHeaderFindEntry(&hdr, HDR_CONTENT_LENGTH);
+       ATF_REQUIRE(e != NULL);
+       ATF_REQUIRE(strNCmp(e->value, clength, strlen(clength)) == 0);
+
+       httpHeaderClean(&hdr);
+}

extern int hh_check_content_length(HttpHeader *hdr, const char *val, int vlen);

@@ -152,6 +168,23 @@
        httpHeaderReset(&hdr);
        httpHeaderClean(&hdr);
 }
+
+ATF_TC(libhttp_parse_content_length_2);
+ATF_TC_HEAD(libhttp_parse_content_length_2, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check that duplicate Content-Length headers are "
+           "correctly replaced with the relaxed HTTP parser enabled");
+}
+
+ATF_TC_BODY(libhttp_parse_content_length_2, tc)
+{
+       test_core_init();
+       httpHeaderInitLibrary();
+       httpConfig_relaxed_parser = 1;
+ libhttp_test_content_length_parser("Content-Length: 12345\r\nContent-Length: 23456\r\n", "23456"); + libhttp_test_content_length_parser("Content-Length: 23456\r\nContent-Length: 12345\r\n", "23456"); + libhttp_test_content_length_parser("Content-Length: 23456\r\nContent-Length: 12345\r\nContent-Length: 23456\r\n", "23456");
+}

 ATF_TP_ADD_TCS(tp)
 {
@@ -160,6 +193,7 @@
        ATF_TP_ADD_TC(tp, libhttp_parse_3);
        ATF_TP_ADD_TC(tp, libhttp_parse_4);
        ATF_TP_ADD_TC(tp, libhttp_parse_content_length_1);
+       ATF_TP_ADD_TC(tp, libhttp_parse_content_length_2);
        return atf_no_error();
 }

--
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en.

Reply via email to