Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update envoy f95f5391 #1140

Merged
merged 12 commits into from
Oct 21, 2020
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion envoy
Submodule envoy updated 1223 files
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue =
static_cast<envoy_filter_headers_status_t>(Envoy::Http::FilterHeadersStatus::Continue);
const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration =
static_cast<envoy_filter_headers_status_t>(Envoy::Http::FilterHeadersStatus::StopIteration);
const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinueAndEndStream =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_cast<envoy_filter_headers_status_t>(
Envoy::Http::FilterHeadersStatus::ContinueAndEndStream);
const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer =
static_cast<envoy_filter_headers_status_t>(
Envoy::Http::FilterHeadersStatus::StopAllIterationAndBuffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 7 additions & 6 deletions library/common/http/dispatcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion library/objective-c/EnvoyEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ typedef NSDictionary<NSString *, NSArray<NSString *> *> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion test/common/http/dispatcher_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<callbacks_called*>(context);
cc->on_trailers_calls++;
Expand Down
12 changes: 6 additions & 6 deletions test/common/http/header_utility_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tools/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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