-
Notifications
You must be signed in to change notification settings - Fork 5.3k
http conn man: add an option to strip trailing host dot. #15568
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
Changes from all commits
7c0674d
d2e05b7
595157c
4945289
74f247f
bb62fda
c3d1057
4b9c804
468ce45
3a4f449
40a1a44
8995b52
baed449
58b3759
e910496
dca8659
fffc458
d3cd808
ef66621
c744100
ec186fd
c94357b
d117486
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1194,6 +1194,47 @@ TEST_F(HttpConnectionManagerImplTest, RouteShouldUseNormalizedHost) { | |
| filter_callbacks_.connection_.raiseEvent(Network::ConnectionEvent::RemoteClose); | ||
| } | ||
|
|
||
| // Observe that we strip the trailing dot. | ||
| TEST_F(HttpConnectionManagerImplTest, StripTrailingHostDot) { | ||
|
Contributor
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. Mind adding a test where we set this config option but pass through a header without a trailing dot?
Contributor
Author
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. Sure. will add. |
||
| setup(false, ""); | ||
| // Enable removal of host's trailing dot. | ||
| strip_trailing_host_dot_ = true; | ||
| const std::string original_host = "host."; | ||
| const std::string updated_host = "host"; | ||
| // Set up the codec. | ||
| Buffer::OwnedImpl fake_input("1234"); | ||
| conn_manager_->createCodec(fake_input); | ||
| // Create a new stream. | ||
| decoder_ = &conn_manager_->newStream(response_encoder_); | ||
| RequestHeaderMapPtr headers{new TestRequestHeaderMapImpl{ | ||
| {":authority", original_host}, {":path", "/"}, {":method", "GET"}}}; | ||
| RequestHeaderMap* updated_headers = headers.get(); | ||
| decoder_->decodeHeaders(std::move(headers), true); | ||
| EXPECT_EQ(updated_host, updated_headers->getHostValue()); | ||
| // Clean up. | ||
| filter_callbacks_.connection_.raiseEvent(Network::ConnectionEvent::RemoteClose); | ||
| } | ||
|
|
||
| TEST_F(HttpConnectionManagerImplTest, HostWithoutTrailingDot) { | ||
| setup(false, ""); | ||
| // Enable removal of host's trailing dot. | ||
| strip_trailing_host_dot_ = true; | ||
| const std::string original_host = "host"; | ||
| const std::string updated_host = "host"; | ||
| // Set up the codec. | ||
| Buffer::OwnedImpl fake_input("1234"); | ||
| conn_manager_->createCodec(fake_input); | ||
| // Create a new stream. | ||
| decoder_ = &conn_manager_->newStream(response_encoder_); | ||
| RequestHeaderMapPtr headers{new TestRequestHeaderMapImpl{ | ||
| {":authority", original_host}, {":path", "/"}, {":method", "GET"}}}; | ||
| RequestHeaderMap* updated_headers = headers.get(); | ||
| decoder_->decodeHeaders(std::move(headers), true); | ||
| EXPECT_EQ(updated_host, updated_headers->getHostValue()); | ||
| // Clean up. | ||
| filter_callbacks_.connection_.raiseEvent(Network::ConnectionEvent::RemoteClose); | ||
| } | ||
|
|
||
| TEST_F(HttpConnectionManagerImplTest, DateHeaderNotPresent) { | ||
| setup(false, ""); | ||
| setUpEncoderAndDecoder(false, false); | ||
|
|
||
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.
This should probably include something about how this handles the host:port case
Uh oh!
There was an error while loading. Please reload this page.
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.
Will following comment helps here in case of host:port?