Skip to content

Commit

Permalink
Fix universal header validation case.
Browse files Browse the repository at this point in the history
When universal header validation is enabled, HTTP_PARSER_STRICT is
defined to be 0, and http-parser gives different error messages.

Signed-off-by: Bence Béky <bnc@google.com>
  • Loading branch information
bnc-google committed Jan 18, 2023
1 parent 657eb01 commit dc62dec
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions test/common/http/http1/codec_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -908,20 +908,25 @@ TEST_P(Http1ServerConnectionImplTest, Http10MultipleResponses) {
}
}

// SPELLCHECKER(off)
struct {
const absl::string_view http_version;
const absl::optional<absl::string_view> balsa_parser_expected_error;
const absl::optional<absl::string_view> http_parser_expected_error;
} kRequestHTTPStringTestCases[] = {{"", {}, {}}, // HTTP/0.9 has no HTTP-version.
{"HTTP/9.1", {}, {}},
{"aHTTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_CONSTANT"},
// SPELLCHECKER(off)
#ifdef ENVOY_ENABLE_UHV
{"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"},
{"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"},
#else
{"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"},
// SPELLCHECKER(on)
{"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"},
#endif
{"FTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_CONSTANT"},
{"HTTP/1.01", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"},
{"HTTP/A.0", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}};
// SPELLCHECKER(on)

TEST_P(Http1ServerConnectionImplTest, HttpVersion) {
for (const auto& test_case : kRequestHTTPStringTestCases) {
Expand Down Expand Up @@ -3837,19 +3842,24 @@ TEST_P(Http1ClientConnectionImplTest, ResponseHttpVersion) {
}
}

// SPELLCHECKER(off)
struct {
const absl::string_view http_version;
const absl::optional<absl::string_view> balsa_parser_expected_error;
const absl::optional<absl::string_view> http_parser_expected_error;
} kResponseHTTPStringTestCases[] = {{"HTTP/9.1", {}, {}},
{"aHTTP/1.1", "HPE_INVALID_CONSTANT", "HPE_INVALID_CONSTANT"},
// SPELLCHECKER(off)
#ifdef ENVOY_ENABLE_UHV
{"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"},
{"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"},
#else
{"HHTTP/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"},
// SPELLCHECKER(on)
{"HTTPS/1.1", "HPE_INVALID_VERSION", "HPE_STRICT"},
#endif
{"FTP/1.1", "HPE_INVALID_CONSTANT", "HPE_INVALID_CONSTANT"},
{"HTTP/1.01", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"},
{"HTTP/A.0", "HPE_INVALID_VERSION", "HPE_INVALID_VERSION"}};
// SPELLCHECKER(on)

TEST_P(Http1ClientConnectionImplTest, HttpVersion) {
for (const auto& test_case : kResponseHTTPStringTestCases) {
Expand Down

0 comments on commit dc62dec

Please sign in to comment.