Skip to content

Commit

Permalink
upstream: fix http health checker not sending :scheme header (#3677)
Browse files Browse the repository at this point in the history
Signed-off-by: Neri Marschik <[email protected]>
  • Loading branch information
codesuki authored and mattklein123 committed Jun 20, 2018
1 parent 08ba248 commit c75fb59
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
1 change: 1 addition & 0 deletions source/common/upstream/health_checker_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ void HttpHealthCheckerImpl::HttpActiveHealthCheckSession::onInterval() {
parent_.host_value_.empty() ? parent_.cluster_.info()->name() : parent_.host_value_},
{Http::Headers::get().Path, parent_.path_},
{Http::Headers::get().UserAgent, Http::Headers::get().UserAgentValues.EnvoyHealthChecker}};
Router::FilterUtility::setUpstreamScheme(request_headers, *parent_.cluster_.info());

parent_.request_headers_parser_->evaluateHeaders(request_headers, REQUEST_INFO);
request_encoder_->encodeHeaders(request_headers, true);
Expand Down
21 changes: 1 addition & 20 deletions test/common/upstream/health_checker_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,9 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheck) {
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_));
EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true))
.WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) {
EXPECT_TRUE(headers.Host());
EXPECT_TRUE(headers.Path());
EXPECT_NE(nullptr, headers.Host());
EXPECT_NE(nullptr, headers.Path());
EXPECT_EQ(headers.Host()->value().c_str(), host);
EXPECT_EQ(headers.Path()->value().c_str(), path);
EXPECT_EQ(headers.Scheme()->value().c_str(), Http::Headers::get().SchemeValues.Http);
}));
health_checker_->start();

Expand Down Expand Up @@ -562,10 +559,6 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithCustomHostValue) {
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_));
EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true))
.WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) {
EXPECT_TRUE(headers.Host());
EXPECT_TRUE(headers.Path());
EXPECT_NE(nullptr, headers.Host());
EXPECT_NE(nullptr, headers.Path());
EXPECT_EQ(headers.Host()->value().c_str(), host);
EXPECT_EQ(headers.Path()->value().c_str(), path);
}));
Expand Down Expand Up @@ -607,14 +600,6 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithAdditionalHeaders) {
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_));
EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true))
.WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) {
EXPECT_TRUE(headers.get(headerOk));
EXPECT_TRUE(headers.get(headerCool));
EXPECT_TRUE(headers.get(headerAwesome));

EXPECT_NE(nullptr, headers.get(headerOk));
EXPECT_NE(nullptr, headers.get(headerCool));
EXPECT_NE(nullptr, headers.get(headerAwesome));

EXPECT_EQ(headers.get(headerOk)->value().c_str(), valueOk);
EXPECT_EQ(headers.get(headerCool)->value().c_str(), valueCool);
EXPECT_EQ(headers.get(headerAwesome)->value().c_str(), valueAwesome);
Expand Down Expand Up @@ -1316,10 +1301,6 @@ TEST_F(HttpHealthCheckerImplTest, SuccessServiceCheckWithAltPort) {
EXPECT_CALL(*test_sessions_[0]->timeout_timer_, enableTimer(_));
EXPECT_CALL(test_sessions_[0]->request_encoder_, encodeHeaders(_, true))
.WillOnce(Invoke([&](const Http::HeaderMap& headers, bool) {
EXPECT_TRUE(headers.Host());
EXPECT_TRUE(headers.Path());
EXPECT_NE(nullptr, headers.Host());
EXPECT_NE(nullptr, headers.Path());
EXPECT_EQ(headers.Host()->value().c_str(), host);
EXPECT_EQ(headers.Path()->value().c_str(), path);
}));
Expand Down

0 comments on commit c75fb59

Please sign in to comment.