diff --git a/envoy b/envoy index ed1ee215df..f95f5391b0 160000 --- a/envoy +++ b/envoy @@ -1 +1 @@ -Subproject commit ed1ee215dff93c50d5d4770cb1f6dc7e419f6c3d +Subproject commit f95f5391b0b8683081ec786ea946026594955fc6 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..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 kEnvoyFilterHeadersStatusContinueAndEndStream = - static_cast( - Envoy::Http::FilterHeadersStatus::ContinueAndEndStream); 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 1e63e15c5e..f4e443b546 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 kEnvoyFilterHeadersStatusContinueAndEndStream; 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..4ae330b38e 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,14 @@ 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 87181f1de7..93dfe43b5f 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 kEnvoyFilterHeadersStatusContinueAndEndStream; extern const int kEnvoyFilterHeadersStatusStopAllIterationAndBuffer; /// Return codes for on-data filter invocations. @see envoy/http/filter.h 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 dbff60bfbc..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 @@ -229,9 +229,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) { @@ -292,9 +293,10 @@ platform_filter_name: StopOnRequestHeadersThenResumeOnResumeDecoding resume_post_cb(); 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, AsyncResumeDecodingIsNoopAfterPreviousResume) { @@ -351,9 +353,10 @@ 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(), - "12"); + 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; EXPECT_CALL(dispatcher_, post(_)).WillOnce(SaveArg<0>(&resume_post_cb)); @@ -604,9 +607,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) { @@ -772,9 +776,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) { @@ -899,17 +904,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 @@ -995,9 +1002,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) { @@ -1058,9 +1066,10 @@ platform_filter_name: StopOnResponseHeadersThenResumeOnResumeEncoding resume_post_cb(); 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, AsyncResumeEncodingIsNoopAfterPreviousResume) { @@ -1117,9 +1126,10 @@ 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(), - "13"); + 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; EXPECT_CALL(dispatcher_, post(_)).WillOnce(SaveArg<0>(&resume_post_cb)); @@ -1369,9 +1379,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) { @@ -1537,9 +1548,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) { @@ -1664,17 +1676,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); diff --git a/tools/check_format.sh b/tools/check_format.sh index 478e6aa07e..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 \ + --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