------------------------------------------------------------ revno: 13188 revision-id: squid3@treenet.co.nz-20131218030001-s4662gew223waehe parent: squid3@treenet.co.nz-20131218004833-zq2xk9o29aa58ajs committer: Amos Jeffries branch nick: trunk timestamp: Tue 2013-12-17 19:00:01 -0800 message: Add unit tests for method parsing update ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20131218030001-s4662gew223waehe # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 001d9eed18712b83451b0b9f7c981ee591494938 # timestamp: 2013-12-18 13:55:22 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20131218004833-\ # zq2xk9o29aa58ajs # # Begin patch === modified file 'src/tests/testHttpRequestMethod.cc' --- src/tests/testHttpRequestMethod.cc 2013-10-25 00:13:46 +0000 +++ src/tests/testHttpRequestMethod.cc 2013-12-18 03:00:01 +0000 @@ -5,6 +5,7 @@ #include "HttpRequestMethod.h" #include "Mem.h" +#include "SquidConfig.h" #include "testHttpRequestMethod.h" #if HAVE_SSTREAM @@ -83,7 +84,17 @@ 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 @@ 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())); }