From 27e15638c45a0c4f1a4b02ccbd4179e2abc9feed Mon Sep 17 00:00:00 2001 From: Yiming Jin Date: Fri, 23 Apr 2021 14:36:50 -0700 Subject: [PATCH] Skip metadata processing after sending local reply Signed-off-by: Yiming Jin --- source/common/http/filter_manager.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/common/http/filter_manager.cc b/source/common/http/filter_manager.cc index b03a9694986e..1bd7dd45f6d7 100644 --- a/source/common/http/filter_manager.cc +++ b/source/common/http/filter_manager.cc @@ -529,6 +529,12 @@ void FilterManager::decodeHeaders(ActiveStreamDecoderFilter* filter, RequestHead (*entry)->handle_->decodeComplete(); } + // Skip processing metadata after sending local reply + if (state_.local_complete_ && std::next(entry) != decoder_filters_.end()) { + maybeContinueDecoding(continue_data_entry); + return; + } + const bool new_metadata_added = processNewlyAddedMetadata(); // If end_stream is set in headers, and a filter adds new metadata, we need to delay end_stream // in headers by inserting an empty data frame with end_stream set. The empty data frame is sent @@ -542,8 +548,7 @@ void FilterManager::decodeHeaders(ActiveStreamDecoderFilter* filter, RequestHead addDecodedData(*((*entry).get()), empty_data, true); } - if ((!continue_iteration || state_.local_complete_) && - std::next(entry) != decoder_filters_.end()) { + if (!continue_iteration && std::next(entry) != decoder_filters_.end()) { // Stop iteration IFF this is not the last filter. If it is the last filter, continue with // processing since we need to handle the case where a terminal filter wants to buffer, but // a previous filter has added body.