From: Amos Jeffries Date: Wed, 18 Dec 2013 03:00:01 +0000 (-0800) Subject: Add unit tests for method parsing update X-Git-Tag: SQUID_3_5_0_1~457 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35efdb9be42a846b8382a64966a3f4ffc3d78828;p=thirdparty%2Fsquid.git Add unit tests for method parsing update --- diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc index 1e83ed1ce3..b90099422d 100644 --- a/src/tests/testHttpRequestMethod.cc +++ b/src/tests/testHttpRequestMethod.cc @@ -5,6 +5,7 @@ #include "HttpRequestMethod.h" #include "Mem.h" +#include "SquidConfig.h" #include "testHttpRequestMethod.h" #if HAVE_SSTREAM @@ -83,7 +84,17 @@ testHttpRequestMethod::testConstructmethod_t() void testHttpRequestMethod::testImage() { + // relaxed RFC-compliance parse HTTP methods are upgraded to correct case + Config.onoff.relaxed_header_parser = 1; + CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("POST",NULL).image())); + CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("pOsT",NULL).image())); CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post",NULL).image())); + + // strict RFC-compliance parse HTTP methods are case sensitive + Config.onoff.relaxed_header_parser = 0; + CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("POST",NULL).image())); + CPPUNIT_ASSERT_EQUAL(String("pOsT"), String(HttpRequestMethod("pOsT",NULL).image())); + CPPUNIT_ASSERT_EQUAL(String("post"), String(HttpRequestMethod("post",NULL).image())); } /* @@ -117,7 +128,15 @@ testHttpRequestMethod::testNotEqualmethod_t() void testHttpRequestMethod::testStream() { + // relaxed RFC-compliance parse HTTP methods are upgraded to correct case + Config.onoff.relaxed_header_parser = 1; std::ostringstream buffer; - buffer << HttpRequestMethod("get",NULL); + buffer << HttpRequestMethod("get", NULL); CPPUNIT_ASSERT_EQUAL(String("GET"), String(buffer.str().c_str())); + + // strict RFC-compliance parse HTTP methods are case sensitive + Config.onoff.relaxed_header_parser = 0; + std::ostringstream buffer2; + buffer2 << HttpRequestMethod("get", NULL); + CPPUNIT_ASSERT_EQUAL(String("get"), String(buffer2.str().c_str())); }