From c658339c8ead98639dbfefc3fb07597eb7646a1a Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 15:46:10 -0700 Subject: [PATCH 01/11] update envoy Signed-off-by: Jose Nino --- envoy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envoy b/envoy index ed1ee215df..c82a5189b1 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit ed1ee215dff93c50d5d4770cb1f6dc7e419f6c3d +Subproject commit c82a5189b19456d53bc9dcab111b04bbc5668473 From a9dbcffde1f7596de34bee7df159a4346f446fac Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:11:14 -0700 Subject: [PATCH 02/11] fixes Signed-off-by: Jose Nino --- .../http/platform_bridge/c_type_definitions.h | 2 +- .../filters/http/platform_bridge/c_types.h | 2 +- library/common/http/dispatcher.cc | 14 ++++++++------ library/objective-c/EnvoyEngine.h | 2 +- tools/check_format.sh | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h b/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h index 9cd88a1307..a9f62bbf9f 100644 --- a/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h +++ b/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h @@ -7,7 +7,7 @@ const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue = static_cast(Envoy::Http::FilterHeadersStatus::Continue); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration = static_cast(Envoy::Http::FilterHeadersStatus::StopIteration); -const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndEndStream = +const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndDontEndStream = static_cast( Envoy::Http::FilterHeadersStatus::ContinueAndEndStream); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer = diff --git a/library/common/extensions/filters/http/platform_bridge/c_types.h b/library/common/extensions/filters/http/platform_bridge/c_types.h index b04298f2da..7ee5395302 100644 --- a/library/common/extensions/filters/http/platform_bridge/c_types.h +++ b/library/common/extensions/filters/http/platform_bridge/c_types.h @@ -20,7 +20,7 @@ extern const envoy_headers envoy_unaltered_headers; typedef int envoy_filter_headers_status_t; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration; -extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndEndStream; +extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndDontEndStream; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer; // Note this return status is unique to platform filters and used only to resume iteration after // it has been previously stopped. diff --git a/library/common/http/dispatcher.cc b/library/common/http/dispatcher.cc index 52809a6011..adae4c7d39 100644 --- a/library/common/http/dispatcher.cc +++ b/library/common/http/dispatcher.cc @@ -51,7 +51,7 @@ void Dispatcher::DirectStreamCallbacks::encodeHeaders(const ResponseHeaderMap& h // Error path: missing EnvoyUpstreamServiceTime implies this is a local reply, which we treat as // a stream error. - if (!success_ && headers.get(Headers::get().EnvoyUpstreamServiceTime) == nullptr) { + if (!success_ && headers.get(Headers::get().EnvoyUpstreamServiceTime).empty()) { ENVOY_LOG(debug, "[S{}] intercepted local response", direct_stream_.stream_handle_); mapLocalResponseToError(headers); if (end_stream) { @@ -427,13 +427,15 @@ void Dispatcher::setDestinationCluster(HeaderMap& headers) { // TODO(junr03): once http3 is available this would probably benefit from some sort of struct that // maps to appropriate cluster names. However, with only two options (http1/2) this suffices. bool use_h2_cluster{}; - const HeaderEntry* entry = headers.get(H2UpstreamHeader); - if (entry) { - if (entry->value() == "http2") { + auto get_result = headers.get(H2UpstreamHeader); + if (!get_result.empty()) { + ASSERT(get_result.size() == 1); + const auto value = get_result[0]->value().getStringView(); + if (value == "http2") { use_h2_cluster = true; } else { - ASSERT(entry->value() == "http1", - fmt::format("using unsupported protocol version {}", entry->value().getStringView())); + ASSERT(value == "http1", + fmt::format("using unsupported protocol version {}", value)); } headers.remove(H2UpstreamHeader); } diff --git a/library/objective-c/EnvoyEngine.h b/library/objective-c/EnvoyEngine.h index f94fd6ebdd..f9c3c82975 100644 --- a/library/objective-c/EnvoyEngine.h +++ b/library/objective-c/EnvoyEngine.h @@ -60,7 +60,7 @@ typedef NSDictionary *> EnvoyHeaders; /// Return codes for on-headers filter invocations. @see envoy/http/filter.h extern const int kEnvoyFilterHeadersStatusContinue; extern const int kEnvoyFilterHeadersStatusStopIteration; -extern const int kEnvoyFilterHeadersStatusContinueAndEndStream; +extern const int kEnvoyFilterHeadersStatusContinueAndDontEndStream; extern const int kEnvoyFilterHeadersStatusStopAllIterationAndBuffer; /// Return codes for on-data filter invocations. @see envoy/http/filter.h diff --git a/tools/check_format.sh b/tools/check_format.sh index 478e6aa07e..11027f0f5d 100755 --- a/tools/check_format.sh +++ b/tools/check_format.sh @@ -11,7 +11,7 @@ fi # TODO(mattklein123): WORKSPACE is excluded due to warning about @bazel_tools reference. Fix here # or in the upstream checker. ENVOY_BAZEL_PREFIX=@envoy envoy/tools/code_format/check_format.py \ - --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/Envoy.framework/ ./library/common/config_template.cc \ + --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/Envoy.framework/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl \ --skip_envoy_build_rule_check "$ENVOY_FORMAT_ACTION" \ --namespace_check_excluded_paths ./examples/ ./library/java/ ./library/kotlin ./library/objective-c \ --build_fixer_check_excluded_paths ./BUILD ./dist ./examples ./library/java ./library/kotlin ./library/objective-c ./library/swift ./library/common/extensions From 9a58d0c79a4870e8ee8c87ba6e3e6d3b8d6d6a75 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:13:23 -0700 Subject: [PATCH 03/11] enum Signed-off-by: Jose Nino --- .../filters/http/platform_bridge/c_type_definitions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h b/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h index a9f62bbf9f..03609bd050 100644 --- a/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h +++ b/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h @@ -9,7 +9,7 @@ const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration = static_cast(Envoy::Http::FilterHeadersStatus::StopIteration); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndDontEndStream = static_cast( - Envoy::Http::FilterHeadersStatus::ContinueAndEndStream); + Envoy::Http::FilterHeadersStatus::ContinueAndDontEndStream); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer = static_cast( Envoy::Http::FilterHeadersStatus::StopAllIterationAndBuffer); From 2ee6ea995f7f759ded7812cdd7a78d300c84e079 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:15:05 -0700 Subject: [PATCH 04/11] delete Signed-off-by: Jose Nino --- .../filters/http/platform_bridge/c_type_definitions.h | 3 --- .../common/extensions/filters/http/platform_bridge/c_types.h | 1 - library/objective-c/EnvoyEngine.h | 1 - 3 files changed, 5 deletions(-) diff --git a/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h b/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h index 03609bd050..1f83460725 100644 --- a/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h +++ b/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h @@ -7,9 +7,6 @@ const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue = static_cast(Envoy::Http::FilterHeadersStatus::Continue); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration = static_cast(Envoy::Http::FilterHeadersStatus::StopIteration); -const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndDontEndStream = - static_cast( - Envoy::Http::FilterHeadersStatus::ContinueAndDontEndStream); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer = static_cast( Envoy::Http::FilterHeadersStatus::StopAllIterationAndBuffer); diff --git a/library/common/extensions/filters/http/platform_bridge/c_types.h b/library/common/extensions/filters/http/platform_bridge/c_types.h index 7ee5395302..7564cee977 100644 --- a/library/common/extensions/filters/http/platform_bridge/c_types.h +++ b/library/common/extensions/filters/http/platform_bridge/c_types.h @@ -20,7 +20,6 @@ extern const envoy_headers envoy_unaltered_headers; typedef int envoy_filter_headers_status_t; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration; -extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndDontEndStream; extern const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer; // Note this return status is unique to platform filters and used only to resume iteration after // it has been previously stopped. diff --git a/library/objective-c/EnvoyEngine.h b/library/objective-c/EnvoyEngine.h index f9c3c82975..03fe412f1f 100644 --- a/library/objective-c/EnvoyEngine.h +++ b/library/objective-c/EnvoyEngine.h @@ -60,7 +60,6 @@ typedef NSDictionary *> EnvoyHeaders; /// Return codes for on-headers filter invocations. @see envoy/http/filter.h extern const int kEnvoyFilterHeadersStatusContinue; extern const int kEnvoyFilterHeadersStatusStopIteration; -extern const int kEnvoyFilterHeadersStatusContinueAndDontEndStream; extern const int kEnvoyFilterHeadersStatusStopAllIterationAndBuffer; /// Return codes for on-data filter invocations. @see envoy/http/filter.h From 4c19da1ff01bbb0b71e10d48bcd3ee800c4d8798 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:16:48 -0700 Subject: [PATCH 05/11] include change Signed-off-by: Jose Nino --- envoy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envoy b/envoy index c82a5189b1..f95f5391b0 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit c82a5189b19456d53bc9dcab111b04bbc5668473 +Subproject commit f95f5391b0b8683081ec786ea946026594955fc6 From 1f41348a70f1be7b3923993fdcc93a36b3e44251 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:22:04 -0700 Subject: [PATCH 06/11] fmt Signed-off-by: Jose Nino --- library/common/http/dispatcher.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/library/common/http/dispatcher.cc b/library/common/http/dispatcher.cc index adae4c7d39..4ae330b38e 100644 --- a/library/common/http/dispatcher.cc +++ b/library/common/http/dispatcher.cc @@ -434,8 +434,7 @@ void Dispatcher::setDestinationCluster(HeaderMap& headers) { if (value == "http2") { use_h2_cluster = true; } else { - ASSERT(value == "http1", - fmt::format("using unsupported protocol version {}", value)); + ASSERT(value == "http1", fmt::format("using unsupported protocol version {}", value)); } headers.remove(H2UpstreamHeader); } From 80e0cb0c95dd2290feb8a812e379558d52470959 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:26:03 -0700 Subject: [PATCH 07/11] exclude Signed-off-by: Jose Nino --- tools/check_format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_format.sh b/tools/check_format.sh index 11027f0f5d..85eaf31aa6 100755 --- a/tools/check_format.sh +++ b/tools/check_format.sh @@ -11,7 +11,7 @@ fi # TODO(mattklein123): WORKSPACE is excluded due to warning about @bazel_tools reference. Fix here # or in the upstream checker. ENVOY_BAZEL_PREFIX=@envoy envoy/tools/code_format/check_format.py \ - --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/Envoy.framework/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl \ + --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/Envoy.framework/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl ./bazel/envoy_mobile_repositories.bzl:79 \ --skip_envoy_build_rule_check "$ENVOY_FORMAT_ACTION" \ --namespace_check_excluded_paths ./examples/ ./library/java/ ./library/kotlin ./library/objective-c \ --build_fixer_check_excluded_paths ./BUILD ./dist ./examples ./library/java ./library/kotlin ./library/objective-c ./library/swift ./library/common/extensions From d10f0cf9030e214adf9e19f4f22e1a3b912c0f9c Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 16:30:24 -0700 Subject: [PATCH 08/11] silly Signed-off-by: Jose Nino --- tools/check_format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/check_format.sh b/tools/check_format.sh index 85eaf31aa6..2588cdb68f 100755 --- a/tools/check_format.sh +++ b/tools/check_format.sh @@ -11,7 +11,7 @@ fi # TODO(mattklein123): WORKSPACE is excluded due to warning about @bazel_tools reference. Fix here # or in the upstream checker. ENVOY_BAZEL_PREFIX=@envoy envoy/tools/code_format/check_format.py \ - --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/Envoy.framework/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl ./bazel/envoy_mobile_repositories.bzl:79 \ + --add-excluded-prefixes ./envoy/ ./envoy_build_config/extensions_build_config.bzl ./WORKSPACE ./dist/Envoy.framework/ ./library/common/config_template.cc ./bazel/envoy_mobile_swift_bazel_support.bzl ./bazel/envoy_mobile_repositories.bzl \ --skip_envoy_build_rule_check "$ENVOY_FORMAT_ACTION" \ --namespace_check_excluded_paths ./examples/ ./library/java/ ./library/kotlin ./library/objective-c \ --build_fixer_check_excluded_paths ./BUILD ./dist ./examples ./library/java ./library/kotlin ./library/objective-c ./library/swift ./library/common/extensions From 1fd195ac9c0810292c6d396c40bcca81fb755554 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 18:52:46 -0700 Subject: [PATCH 09/11] green tests Signed-off-by: Jose Nino --- .../platform_bridge_filter_test.cc | 81 +++++++++++-------- test/common/http/dispatcher_test.cc | 2 +- test/common/http/header_utility_test.cc | 12 +-- 3 files changed, 53 insertions(+), 42 deletions(-) diff --git a/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc b/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc index 4a62ed5579..afadd6d97e 100644 --- a/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc +++ b/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc @@ -226,9 +226,10 @@ platform_filter_name: StopOnRequestHeadersThenResumeOnData EXPECT_EQ(Http::FilterDataStatus::Continue, filter_->decodeData(request_data, true)); EXPECT_EQ(invocations.on_request_data_calls, 1); - EXPECT_TRUE(request_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), - "12"); + EXPECT_FALSE(request_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ( + request_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "12"); } TEST_F(PlatformBridgeFilterTest, StopOnRequestHeadersThenResumeOnResumeDecoding) { @@ -286,9 +287,10 @@ platform_filter_name: StopOnRequestHeadersThenResumeOnResumeDecoding filter_->onResumeDecoding(); EXPECT_EQ(invocations.on_resume_request_calls, 1); - EXPECT_TRUE(request_headers.get(Http::LowerCaseString("x-async-resumed"))); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("x-async-resumed"))->value().getStringView(), - "Very Yes"); + EXPECT_FALSE(request_headers.get(Http::LowerCaseString("x-async-resumed")).empty()); + EXPECT_EQ( + request_headers.get(Http::LowerCaseString("x-async-resumed"))[0]->value().getStringView(), + "Very Yes"); } TEST_F(PlatformBridgeFilterTest, BasicContinueOnRequestData) { @@ -532,9 +534,10 @@ platform_filter_name: StopOnRequestHeadersThenBufferThenResumeOnData EXPECT_EQ(decoding_buffer.toString(), "C"); // Pending headers have been updated with value from ResumeIteration. - EXPECT_TRUE(request_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), - "1"); + EXPECT_FALSE(request_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ( + request_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "1"); } TEST_F(PlatformBridgeFilterTest, StopNoBufferOnRequestData) { @@ -700,9 +703,10 @@ platform_filter_name: StopOnRequestHeadersThenBufferThenResumeOnTrailers EXPECT_EQ(decoding_buffer.toString(), "C"); // Pending headers have been updated with value from ResumeIteration. - EXPECT_TRUE(request_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), - "1"); + EXPECT_FALSE(request_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ( + request_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "1"); } TEST_F(PlatformBridgeFilterTest, StopOnRequestHeadersThenBufferThenResumeOnResumeDecoding) { @@ -824,17 +828,19 @@ platform_filter_name: StopOnRequestHeadersThenBufferThenResumeOnResumeDecoding EXPECT_EQ(invocations.on_resume_request_calls, 1); // Pending headers have been updated with the value from ResumeIteration. - EXPECT_TRUE(request_headers.get(Http::LowerCaseString("x-async-resumed"))); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("x-async-resumed"))->value().getStringView(), - "Very Yes"); + EXPECT_FALSE(request_headers.get(Http::LowerCaseString("x-async-resumed")).empty()); + EXPECT_EQ( + request_headers.get(Http::LowerCaseString("x-async-resumed"))[0]->value().getStringView(), + "Very Yes"); // Buffer has been updated with value from ResumeIteration. EXPECT_EQ(decoding_buffer.toString(), "C"); // Pending trailers have been updated with value from ResumeIteration. - EXPECT_TRUE(request_trailers.get(Http::LowerCaseString("x-async-resumed"))); - EXPECT_EQ(request_trailers.get(Http::LowerCaseString("x-async-resumed"))->value().getStringView(), - "yes"); + EXPECT_FALSE(request_trailers.get(Http::LowerCaseString("x-async-resumed")).empty()); + EXPECT_EQ( + request_trailers.get(Http::LowerCaseString("x-async-resumed"))[0]->value().getStringView(), + "yes"); } // DIVIDE @@ -920,9 +926,10 @@ platform_filter_name: StopOnResponseHeadersThenResumeOnData EXPECT_EQ(Http::FilterDataStatus::Continue, filter_->encodeData(response_data, true)); EXPECT_EQ(invocations.on_response_data_calls, 1); - EXPECT_TRUE(response_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), - "13"); + EXPECT_FALSE(response_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ( + response_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "13"); } TEST_F(PlatformBridgeFilterTest, StopOnResponseHeadersThenResumeOnResumeEncoding) { @@ -980,9 +987,10 @@ platform_filter_name: StopOnResponseHeadersThenResumeOnResumeEncoding filter_->onResumeEncoding(); EXPECT_EQ(invocations.on_resume_response_calls, 1); - EXPECT_TRUE(response_headers.get(Http::LowerCaseString("x-async-resumed"))); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("x-async-resumed"))->value().getStringView(), - "Very Yes"); + EXPECT_FALSE(response_headers.get(Http::LowerCaseString("x-async-resumed")).empty()); + EXPECT_EQ( + response_headers.get(Http::LowerCaseString("x-async-resumed"))[0]->value().getStringView(), + "Very Yes"); } TEST_F(PlatformBridgeFilterTest, BasicContinueOnResponseData) { @@ -1225,9 +1233,10 @@ platform_filter_name: StopOnResponseHeadersThenBufferThenResumeOnData EXPECT_EQ(encoding_buffer.toString(), "C"); // Pending headers have been updated with value from ResumeIteration. - EXPECT_TRUE(response_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), - "1"); + EXPECT_FALSE(response_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ( + response_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "1"); } TEST_F(PlatformBridgeFilterTest, StopNoBufferOnResponseData) { @@ -1393,9 +1402,10 @@ platform_filter_name: StopOnResponseHeadersThenBufferThenResumeOnTrailers EXPECT_EQ(encoding_buffer.toString(), "C"); // Pending headers have been updated with value from ResumeIteration. - EXPECT_TRUE(response_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), - "1"); + EXPECT_FALSE(response_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ( + response_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "1"); } TEST_F(PlatformBridgeFilterTest, StopOnResponseHeadersThenBufferThenResumeOnResumeEncoding) { @@ -1517,17 +1527,18 @@ platform_filter_name: StopOnResponseHeadersThenBufferThenResumeOnResumeEncoding EXPECT_EQ(invocations.on_resume_response_calls, 1); // Pending headers have been updated with the value from ResumeIteration. - EXPECT_TRUE(response_headers.get(Http::LowerCaseString("x-async-resumed"))); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("x-async-resumed"))->value().getStringView(), - "Very Yes"); + EXPECT_FALSE(response_headers.get(Http::LowerCaseString("x-async-resumed")).empty()); + EXPECT_EQ( + response_headers.get(Http::LowerCaseString("x-async-resumed"))[0]->value().getStringView(), + "Very Yes"); // Buffer has been updated with value from ResumeIteration. EXPECT_EQ(encoding_buffer.toString(), "C"); // Pending trailers have been updated with value from ResumeIteration. - EXPECT_TRUE(response_trailers.get(Http::LowerCaseString("x-async-resumed"))); + EXPECT_FALSE(response_trailers.get(Http::LowerCaseString("x-async-resumed")).empty()); EXPECT_EQ( - response_trailers.get(Http::LowerCaseString("x-async-resumed"))->value().getStringView(), + response_trailers.get(Http::LowerCaseString("x-async-resumed"))[0]->value().getStringView(), "yes"); } diff --git a/test/common/http/dispatcher_test.cc b/test/common/http/dispatcher_test.cc index fdc4586036..1088d966c2 100644 --- a/test/common/http/dispatcher_test.cc +++ b/test/common/http/dispatcher_test.cc @@ -503,7 +503,7 @@ TEST_F(DispatcherTest, BasicStreamTrailers) { bridge_callbacks.context = &cc; bridge_callbacks.on_trailers = [](envoy_headers c_trailers, void* context) -> void* { ResponseHeaderMapPtr response_trailers = toResponseHeaders(c_trailers); - EXPECT_EQ(response_trailers->get(LowerCaseString("x-test-trailer"))->value().getStringView(), + EXPECT_EQ(response_trailers->get(LowerCaseString("x-test-trailer"))[0]->value().getStringView(), "test_trailer"); callbacks_called* cc = static_cast(context); cc->on_trailers_calls++; diff --git a/test/common/http/header_utility_test.cc b/test/common/http/header_utility_test.cc index bf1ee07fc5..691a093c00 100644 --- a/test/common/http/header_utility_test.cc +++ b/test/common/http/header_utility_test.cc @@ -67,9 +67,9 @@ TEST(RequestHeaderDataConstructorTest, FromCToCpp) { auto expected_value = Utility::convertToString(c_headers_copy.headers[i].value); // Key is present. - EXPECT_NE(cpp_headers->get(expected_key), nullptr); + EXPECT_FALSE(cpp_headers->get(expected_key).empty()); // Value for the key is the same. - EXPECT_EQ(cpp_headers->get(expected_key)->value().getStringView(), expected_value); + EXPECT_EQ(cpp_headers->get(expected_key)[0]->value().getStringView(), expected_value); } release_envoy_headers(c_headers_copy); delete sentinel; @@ -108,9 +108,9 @@ TEST(RequestTrailerDataConstructorTest, FromCToCpp) { auto expected_value = Utility::convertToString(c_trailers_copy.headers[i].value); // Key is present. - EXPECT_NE(cpp_trailers->get(expected_key), nullptr); + EXPECT_FALSE(cpp_trailers->get(expected_key).empty()); // Value for the key is the same. - EXPECT_EQ(cpp_trailers->get(expected_key)->value().getStringView(), expected_value); + EXPECT_EQ(cpp_trailers->get(expected_key)[0]->value().getStringView(), expected_value); } release_envoy_headers(c_trailers_copy); delete sentinel; @@ -139,9 +139,9 @@ TEST(HeaderDataConstructorTest, FromCppToC) { auto actual_value = Utility::convertToString(c_headers.headers[i].value); // Key is present. - EXPECT_NE(cpp_headers->get(actual_key), nullptr); + EXPECT_FALSE(cpp_headers->get(actual_key).empty()); // Value for the key is the same. - EXPECT_EQ(actual_value, cpp_headers->get(actual_key)->value().getStringView()); + EXPECT_EQ(actual_value, cpp_headers->get(actual_key)[0]->value().getStringView()); } release_envoy_headers(c_headers); From 8a7cf0839cb6c50ff9648a9bd3c1f8098f78204f Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 20:10:52 -0700 Subject: [PATCH 10/11] fix main tests Signed-off-by: Jose Nino --- .../http/platform_bridge/platform_bridge_filter_test.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc b/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc index d27d34074c..21916f4dee 100644 --- a/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc +++ b/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc @@ -353,8 +353,8 @@ platform_filter_name: AsyncResumeDecodingIsNoopAfterPreviousResume EXPECT_EQ(Http::FilterDataStatus::Continue, filter_->decodeData(request_data, true)); EXPECT_EQ(invocations.on_request_data_calls, 1); - EXPECT_TRUE(request_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), + EXPECT_FALSE(request_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ(request_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), "12"); Event::PostCb resume_post_cb; @@ -1125,8 +1125,8 @@ platform_filter_name: AsyncResumeEncodingIsNoopAfterPreviousResume EXPECT_EQ(Http::FilterDataStatus::Continue, filter_->encodeData(response_data, true)); EXPECT_EQ(invocations.on_response_data_calls, 1); - EXPECT_TRUE(response_headers.get(Http::LowerCaseString("content-length"))); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("content-length"))->value().getStringView(), + EXPECT_FALSE(response_headers.get(Http::LowerCaseString("content-length")).empty()); + EXPECT_EQ(response_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), "13"); Event::PostCb resume_post_cb; From 37ccd8d72b57b293296fd1466b0c7db9e8413fd6 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Tue, 20 Oct 2020 20:16:11 -0700 Subject: [PATCH 11/11] fmt Signed-off-by: Jose Nino --- .../platform_bridge/platform_bridge_filter_test.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc b/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc index 21916f4dee..a59bc2dae8 100644 --- a/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc +++ b/test/common/extensions/filters/http/platform_bridge/platform_bridge_filter_test.cc @@ -354,8 +354,9 @@ platform_filter_name: AsyncResumeDecodingIsNoopAfterPreviousResume EXPECT_EQ(invocations.on_request_data_calls, 1); EXPECT_FALSE(request_headers.get(Http::LowerCaseString("content-length")).empty()); - EXPECT_EQ(request_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), - "12"); + EXPECT_EQ( + request_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "12"); Event::PostCb resume_post_cb; EXPECT_CALL(dispatcher_, post(_)).WillOnce(SaveArg<0>(&resume_post_cb)); @@ -1126,8 +1127,9 @@ platform_filter_name: AsyncResumeEncodingIsNoopAfterPreviousResume EXPECT_EQ(invocations.on_response_data_calls, 1); EXPECT_FALSE(response_headers.get(Http::LowerCaseString("content-length")).empty()); - EXPECT_EQ(response_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), - "13"); + EXPECT_EQ( + response_headers.get(Http::LowerCaseString("content-length"))[0]->value().getStringView(), + "13"); Event::PostCb resume_post_cb; EXPECT_CALL(dispatcher_, post(_)).WillOnce(SaveArg<0>(&resume_post_cb));