-
Notifications
You must be signed in to change notification settings - Fork 5.3k
HCM: guard Envoy from removal of critical response headers. #15658
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
3b0cebf
16a9c78
0571faa
0fd4855
3e0b74a
928717c
52f9319
9f4628d
f7d37b8
7fca42d
0dafb70
5c564ad
59cc65d
719c1be
ce54947
16d93ff
e4d8e9f
7f19036
747211c
017e9c7
a979014
af9865a
e25c790
e6dd0ca
4a4a181
7421efd
e51dbc9
8434064
efdc243
7093416
b91f23b
1034e00
a0b8b3a
e8fd6d9
174e51a
0c8c649
c7eda3c
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -1011,8 +1011,10 @@ void FilterManager::maybeContinueEncoding( | |||||||
| void FilterManager::encodeHeaders(ActiveStreamEncoderFilter* filter, ResponseHeaderMap& headers, | ||||||||
| bool end_stream) { | ||||||||
| // See encodeHeaders() comments in include/envoy/http/filter.h for why the 1xx precondition holds. | ||||||||
| ASSERT(!CodeUtility::is1xx(Utility::getResponseStatus(headers)) || | ||||||||
| Utility::getResponseStatus(headers) == enumToInt(Http::Code::SwitchingProtocols)); | ||||||||
| ASSERT(HeaderUtility::checkRequiredResponseHeaders(headers).ok() && | ||||||||
| (!CodeUtility::is1xx(Utility::getResponseStatus(headers)) || | ||||||||
| Utility::getResponseStatus(headers) == enumToInt(Http::Code::SwitchingProtocols))); | ||||||||
|
|
||||||||
| filter_manager_callbacks_.resetIdleTimer(); | ||||||||
| disarmRequestTimeout(); | ||||||||
|
|
||||||||
|
|
@@ -1065,8 +1067,8 @@ void FilterManager::encodeHeaders(ActiveStreamEncoderFilter* filter, ResponseHea | |||||||
| } | ||||||||
|
|
||||||||
| const bool modified_end_stream = (end_stream && continue_data_entry == encoder_filters_.end()); | ||||||||
| state_.non_100_response_headers_encoded_ = true; | ||||||||
| filter_manager_callbacks_.encodeHeaders(headers, modified_end_stream); | ||||||||
| state_.non_100_response_headers_encoded_ = true; | ||||||||
|
Member
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. this change is necessary since there's a check of |
||||||||
| maybeEndEncode(modified_end_stream); | ||||||||
|
|
||||||||
| if (!modified_end_stream) { | ||||||||
|
|
@@ -1247,7 +1249,10 @@ void FilterManager::encodeTrailers(ActiveStreamEncoderFilter* filter, | |||||||
| } | ||||||||
|
|
||||||||
| void FilterManager::maybeEndEncode(bool end_stream) { | ||||||||
| if (end_stream) { | ||||||||
| // filter_manager_callbacks_.streamEnded() returns True here when the codec failed to encode | ||||||||
| // headers due to the lack of required response headers, and filter_manager_callbacks already sent | ||||||||
| // the local reply and ended the stream by itself. So in that case this function must be no-op. | ||||||||
| if (end_stream && !filter_manager_callbacks_.streamEnded()) { | ||||||||
|
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. where are we now calling maybeEndEncode after the stream already ended?
Member
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. that is when the local reply is sent (due to the missing requires response headers) in the envoy/source/common/http/filter_manager.cc Lines 1070 to 1072 in 174e51a
But yeah I think this made the code a little bit more complex so maybe we should just return the status from filter_manager_callbacks and send the LocalReply just before maybeEndEncode in FilterManager..
Member
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. WDYT?
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. Yeah, I think I'd rather have the HCM encodeHeaders return a status, so the filter manager knows something has gone awry. |
||||||||
| filter_manager_callbacks_.endStream(); | ||||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.