-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip metadata processing after sending local reply (#16154)
Signed-off-by: Yiming Jin <[email protected]>
- Loading branch information
Showing
5 changed files
with
81 additions
and
2 deletions.
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
40 changes: 40 additions & 0 deletions
40
test/integration/filters/local_reply_with_metadata_filter.cc
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "envoy/registry/registry.h" | ||
#include "envoy/server/filter_config.h" | ||
|
||
#include "extensions/filters/http/common/pass_through_filter.h" | ||
|
||
#include "test/extensions/filters/http/common/empty_http_filter_config.h" | ||
#include "test/integration/filters/common.h" | ||
|
||
#include "gtest/gtest.h" | ||
|
||
namespace Envoy { | ||
|
||
// A filter that calls Http::FilterHeadersStatus::StopAll and set metadata after a local reply. | ||
class LocalReplyWithMetadataFilter : public Http::PassThroughFilter { | ||
public: | ||
constexpr static char name[] = "local-reply-with-metadata-filter"; | ||
|
||
Http::FilterHeadersStatus decodeHeaders(Http::RequestHeaderMap&, bool) override { | ||
Http::MetadataMap metadata_map = {{"headers", "headers"}, {"duplicate", "duplicate"}}; | ||
Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
decoder_callbacks_->addDecodedMetadata().emplace_back(std::move(metadata_map_ptr)); | ||
decoder_callbacks_->sendLocalReply(Envoy::Http::Code::OK, "", nullptr, absl::nullopt, | ||
"LocalReplyWithMetadataFilter is ready"); | ||
return Http::FilterHeadersStatus::StopIteration; | ||
} | ||
|
||
// Adds new metadata to metadata_map directly | ||
Http::FilterMetadataStatus decodeMetadata(Http::MetadataMap& metadata_map) override { | ||
metadata_map["data"] = "data"; | ||
ASSERT(false); | ||
return Http::FilterMetadataStatus::Continue; | ||
} | ||
}; | ||
|
||
constexpr char LocalReplyWithMetadataFilter::name[]; | ||
static Registry::RegisterFactory<SimpleFilterConfig<LocalReplyWithMetadataFilter>, | ||
Server::Configuration::NamedHttpFilterConfigFactory> | ||
register_; | ||
|
||
} // namespace Envoy |
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