]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
parserNG: add missing unit test for HTTP/0.9 case
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 9 Nov 2014 14:57:25 +0000 (06:57 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 9 Nov 2014 14:57:25 +0000 (06:57 -0800)
src/tests/testHttp1Parser.cc

index fe262dca2609017d846d3579da6c3ca8b970b526..716e728a670d605bef899f1268341701d4dfaa16 100644 (file)
@@ -1017,6 +1017,7 @@ testHttp1Parser::testParseRequestLineInvalid()
 
     // no method (an invalid format)
     {
+        input.append(" / HTTP/1.0\n", 12);
 #if USE_HTTP_VIOLATIONS
         // squid custom tolerance consumes initial SP.
         Config.onoff.relaxed_header_parser = 1;
@@ -1045,8 +1046,6 @@ testHttp1Parser::testParseRequestLineInvalid()
 #if !USE_HTTP_VIOLATIONS
         // a compliant or strict parse, detects as invalid
         Config.onoff.relaxed_header_parser = 0;
-#endif
-        input.append(" / HTTP/1.0\n", 12);
         struct resultSet expectStrict = {
             .parsed = false,
             .needsMore = false,
@@ -1065,6 +1064,27 @@ testHttp1Parser::testParseRequestLineInvalid()
             .versionEnd = -1,
             .version = AnyP::ProtocolVersion()
         };
+#else
+        // XXX: for now Squid confuses this with HTTP/0.9
+        struct resultSet expectStrict = {
+            .parsed = true,
+            .needsMore = false,
+            .parserState = Http1::HTTP_PARSE_DONE,
+            .status = Http::scOkay,
+            .msgStart = 0,
+            .msgEnd = (int)input.length()-2,
+            .suffixSz = 0,
+            .methodStart = 0,
+            .methodEnd = 0,
+            .method = HttpRequestMethod(SBuf("/")),
+            .uriStart = 2,
+            .uriEnd = 9,
+            .uri = "HTTP/1.0",
+            .versionStart = -1,
+            .versionEnd = -1,
+            .version = AnyP::ProtocolVersion(AnyP::PROTO_HTTP,0,9)
+        };
+#endif
         output.clear();
         testResults(__LINE__, input, output, expectStrict);
         input.clear();