-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
http: fixing up CONNECT to be RFC compliant #21440
Changes from all commits
f327436
f140470
1022eea
a87a0f9
bb73c07
0709f9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include "test/mocks/tcp/mocks.h" | ||
#include "test/test_common/environment.h" | ||
#include "test/test_common/network_utility.h" | ||
#include "test/test_common/test_runtime.h" | ||
|
||
#include "gmock/gmock.h" | ||
#include "gtest/gtest.h" | ||
|
@@ -223,7 +224,10 @@ template <typename T> class HttpUpstreamRequestEncoderTest : public testing::Tes | |
|
||
TYPED_TEST_SUITE(HttpUpstreamRequestEncoderTest, Implementations); | ||
|
||
TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoder) { | ||
TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoderOld) { | ||
TestScopedRuntime scoped_runtime; | ||
scoped_runtime.mergeValues({{"envoy.reloadable_features.use_rfc_connect", "false"}}); | ||
|
||
this->setupUpstream(); | ||
std::unique_ptr<Http::RequestHeaderMapImpl> expected_headers; | ||
expected_headers = Http::createHeaderMap<Http::RequestHeaderMapImpl>({ | ||
|
@@ -243,6 +247,18 @@ TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoder) { | |
this->upstream_->setRequestEncoder(this->encoder_, false); | ||
} | ||
|
||
TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoder) { | ||
this->setupUpstream(); | ||
std::unique_ptr<Http::RequestHeaderMapImpl> expected_headers; | ||
expected_headers = Http::createHeaderMap<Http::RequestHeaderMapImpl>({ | ||
{Http::Headers::get().Method, "CONNECT"}, | ||
{Http::Headers::get().Host, this->config_->hostname()}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great, thanks for the fix! One possibly concern is that in the current code we are using a header to replace Host, which allows dynamic metadata ( TunnelingConfig: &tcp.TcpProxy_TunnelingConfig{
Hostname: "ignored",
HeadersToAdd: []*core.HeaderValueOption{
{Header: &core.HeaderValue{Key: "x-destination", Value: "%DYNAMIC_METADATA([\"tunnel\", \"address\"])%"}},
},
}, ). Now we would want to use Hostname to follow the spec, but that is only a static string. Seems like something that could be expanded in a followup though @lambdai There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
}); | ||
|
||
EXPECT_CALL(this->encoder_, encodeHeaders(HeaderMapEqualRef(expected_headers.get()), false)); | ||
this->upstream_->setRequestEncoder(this->encoder_, false); | ||
} | ||
|
||
TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoderUsePost) { | ||
this->config_message_.set_use_post(true); | ||
this->setupUpstream(); | ||
|
@@ -287,14 +303,6 @@ TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoderHeaders) { | |
{Http::Headers::get().Host, this->config_->hostname()}, | ||
}); | ||
|
||
if (this->is_http2_) { | ||
expected_headers->setReferenceKey(Http::Headers::get().Path, "/"); | ||
expected_headers->setReferenceKey(Http::Headers::get().Scheme, | ||
Http::Headers::get().SchemeValues.Http); | ||
expected_headers->setReferenceKey(Http::Headers::get().Protocol, | ||
Http::Headers::get().ProtocolValues.Bytestream); | ||
} | ||
|
||
expected_headers->setCopy(Http::LowerCaseString("header0"), "value0"); | ||
expected_headers->addCopy(Http::LowerCaseString("header1"), "value1"); | ||
expected_headers->addCopy(Http::LowerCaseString("header1"), "value2"); | ||
|
@@ -323,25 +331,9 @@ TYPED_TEST(HttpUpstreamRequestEncoderTest, ConfigReuse) { | |
{Http::Headers::get().Host, this->config_->hostname()}, | ||
}); | ||
|
||
if (this->is_http2_) { | ||
expected_headers->setReferenceKey(Http::Headers::get().Path, "/"); | ||
expected_headers->setReferenceKey(Http::Headers::get().Scheme, | ||
Http::Headers::get().SchemeValues.Http); | ||
expected_headers->setReferenceKey(Http::Headers::get().Protocol, | ||
Http::Headers::get().ProtocolValues.Bytestream); | ||
} | ||
|
||
expected_headers->setCopy(Http::LowerCaseString("key"), "value1"); | ||
expected_headers->addCopy(Http::LowerCaseString("key"), "value2"); | ||
|
||
if (this->is_http2_) { | ||
expected_headers->setReferenceKey(Http::Headers::get().Path, "/"); | ||
expected_headers->setReferenceKey(Http::Headers::get().Scheme, | ||
Http::Headers::get().SchemeValues.Http); | ||
expected_headers->setReferenceKey(Http::Headers::get().Protocol, | ||
Http::Headers::get().ProtocolValues.Bytestream); | ||
} | ||
|
||
expected_headers->setCopy(Http::LowerCaseString("key"), "value1"); | ||
expected_headers->addCopy(Http::LowerCaseString("key"), "value2"); | ||
|
||
|
@@ -382,14 +374,6 @@ TYPED_TEST(HttpUpstreamRequestEncoderTest, RequestEncoderHeadersWithDownstreamIn | |
{Http::Headers::get().Host, this->config_->hostname()}, | ||
}); | ||
|
||
if (this->is_http2_) { | ||
expected_headers->setReferenceKey(Http::Headers::get().Path, "/"); | ||
expected_headers->setReferenceKey(Http::Headers::get().Scheme, | ||
Http::Headers::get().SchemeValues.Http); | ||
expected_headers->setReferenceKey(Http::Headers::get().Protocol, | ||
Http::Headers::get().ProtocolValues.Bytestream); | ||
} | ||
|
||
expected_headers->setCopy(Http::LowerCaseString("header0"), "value0"); | ||
expected_headers->addCopy(Http::LowerCaseString("downstream_local_port"), "80"); | ||
auto ip_versions = TestEnvironment::getIpVersionsForTest(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -303,16 +303,11 @@ TEST_P(LocalJwksIntegrationTest, ConnectRequestWithRegExMatch) { | |
request_encoder_ = &encoder_decoder.first; | ||
auto response = std::move(encoder_decoder.second); | ||
|
||
if (downstreamProtocol() == Http::CodecType::HTTP1) { | ||
// Because CONNECT requests for HTTP/1 do not include a path, they will fail | ||
// to find a route match and return a 404. | ||
ASSERT_TRUE(response->waitForEndStream()); | ||
ASSERT_TRUE(response->complete()); | ||
EXPECT_EQ("404", response->headers().getStatusValue()); | ||
} else { | ||
ASSERT_TRUE(response->waitForReset()); | ||
ASSERT_TRUE(codec_client_->waitForDisconnect()); | ||
} | ||
// Because CONNECT requests do not include a path, they will fail | ||
// to find a route match and return a 404. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is a change in behavior that is visible to this filter. Presumably that's ok (and expected). Is there any need to call this out in release notes, or anything? Probably not, since they already mention the flag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that's my thought |
||
ASSERT_TRUE(response->waitForEndStream()); | ||
ASSERT_TRUE(response->complete()); | ||
EXPECT_EQ("404", response->headers().getStatusValue()); | ||
} | ||
|
||
// The test case with a fake upstream for remote Jwks server. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we consider moving the comment from line 296 down into the
if
blocks and editing it accordingly?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done