From a6950c2df079302e4fadd7675570ca4d4da0f4fd Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sun, 9 Nov 2014 06:57:25 -0800 Subject: [PATCH] parserNG: add missing unit test for HTTP/0.9 case --- src/tests/testHttp1Parser.cc | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/tests/testHttp1Parser.cc b/src/tests/testHttp1Parser.cc index fe262dca26..716e728a67 100644 --- a/src/tests/testHttp1Parser.cc +++ b/src/tests/testHttp1Parser.cc @@ -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(); -- 2.47.3