-
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 connection close behavior #10957
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1e018fd
http: fixing connection close behavior
alyssawilk caf7388
Merge branch 'refs/heads/master' into hcm_todo
alyssawilk b2e48bf
runtime guarding
alyssawilk 45c9076
Merge branch 'refs/heads/master' into hcm_todo
alyssawilk d6e73ad
test cleanup
alyssawilk f502fe5
Merge branch 'master' into hcm_todo
alyssawilk a9b9347
Merge branch 'master' into hcm_todo
alyssawilk ac320b1
reviewer comments
alyssawilk 632b175
legacy tests
alyssawilk c705a09
Merge branch 'master' into hcm_todo
alyssawilk 8e1d417
Merge branch 'master' into hcm_todo
alyssawilk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
#include "common/http/codec_client.h" | ||
#include "common/http/codes.h" | ||
#include "common/http/header_utility.h" | ||
#include "common/http/headers.h" | ||
#include "common/runtime/runtime_features.h" | ||
|
||
|
@@ -81,23 +82,30 @@ ConnPoolImpl::StreamWrapper::~StreamWrapper() { | |
void ConnPoolImpl::StreamWrapper::onEncodeComplete() { encode_complete_ = true; } | ||
|
||
void ConnPoolImpl::StreamWrapper::decodeHeaders(ResponseHeaderMapPtr&& headers, bool end_stream) { | ||
// If Connection: close OR | ||
// Http/1.0 and not Connection: keep-alive OR | ||
// Proxy-Connection: close | ||
if ((headers->Connection() && | ||
(absl::EqualsIgnoreCase(headers->Connection()->value().getStringView(), | ||
Headers::get().ConnectionValues.Close))) || | ||
(parent_.codec_client_->protocol() == Protocol::Http10 && | ||
(!headers->Connection() || | ||
!absl::EqualsIgnoreCase(headers->Connection()->value().getStringView(), | ||
Headers::get().ConnectionValues.KeepAlive))) || | ||
(headers->ProxyConnection() && | ||
(absl::EqualsIgnoreCase(headers->ProxyConnection()->value().getStringView(), | ||
Headers::get().ConnectionValues.Close)))) { | ||
parent_.parent_.host_->cluster().stats().upstream_cx_close_notify_.inc(); | ||
close_connection_ = true; | ||
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.fixed_connection_close")) { | ||
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. If we are going to runtime guard this can we add tests for both cases for the conn pool and health checker? |
||
close_connection_ = | ||
HeaderUtility::shouldCloseConnection(parent_.codec_client_->protocol(), *headers); | ||
if (close_connection_) { | ||
parent_.parent_.host_->cluster().stats().upstream_cx_close_notify_.inc(); | ||
} | ||
} else { | ||
// If Connection: close OR | ||
// Http/1.0 and not Connection: keep-alive OR | ||
// Proxy-Connection: close | ||
if ((headers->Connection() && | ||
(absl::EqualsIgnoreCase(headers->Connection()->value().getStringView(), | ||
Headers::get().ConnectionValues.Close))) || | ||
(parent_.codec_client_->protocol() == Protocol::Http10 && | ||
(!headers->Connection() || | ||
!absl::EqualsIgnoreCase(headers->Connection()->value().getStringView(), | ||
Headers::get().ConnectionValues.KeepAlive))) || | ||
(headers->ProxyConnection() && | ||
(absl::EqualsIgnoreCase(headers->ProxyConnection()->value().getStringView(), | ||
Headers::get().ConnectionValues.Close)))) { | ||
parent_.parent_.host_->cluster().stats().upstream_cx_close_notify_.inc(); | ||
close_connection_ = true; | ||
} | ||
} | ||
|
||
ResponseDecoderWrapper::decodeHeaders(std::move(headers), end_stream); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: s/saw_connection_close_/should_close_connection_ or something since I think the meaning of this over time is now different?