-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto-merge envoyproxy/envoy[main] into envoyproxy/envoy-openssl[main]
* upstream/main: Handle encode metadata after recreated stream (#36427) mobile: Fix broken link (#36436)
- Loading branch information
Showing
8 changed files
with
225 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <chrono> | ||
#include <string> | ||
|
||
#include "envoy/event/timer.h" | ||
#include "envoy/http/filter.h" | ||
#include "envoy/registry/registry.h" | ||
#include "envoy/server/filter_config.h" | ||
|
||
#include "source/common/buffer/buffer_impl.h" | ||
#include "source/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 add encoded metadata in encodeHeaders. | ||
class AddEncodeMetadataFilter : public Http::PassThroughFilter { | ||
public: | ||
constexpr static char name[] = "add-metadata-encode-headers-filter"; | ||
|
||
Http::FilterHeadersStatus encodeHeaders(Http::ResponseHeaderMap&, bool) override { | ||
Http::MetadataMap metadata_map = {{"headers", "headers"}, {"duplicate", "duplicate"}}; | ||
Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
return Http::FilterHeadersStatus::Continue; | ||
} | ||
|
||
Http::FilterDataStatus encodeData(Buffer::Instance&, bool) override { | ||
return Http::FilterDataStatus::Continue; | ||
} | ||
}; | ||
|
||
constexpr char AddEncodeMetadataFilter::name[]; | ||
static Registry::RegisterFactory<SimpleFilterConfig<AddEncodeMetadataFilter>, | ||
Server::Configuration::NamedHttpFilterConfigFactory> | ||
register_; | ||
|
||
} // namespace Envoy |
55 changes: 55 additions & 0 deletions
55
test/integration/filters/encoder_recreate_stream_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,55 @@ | ||
#include <chrono> | ||
#include <string> | ||
|
||
#include "envoy/event/timer.h" | ||
#include "envoy/http/filter.h" | ||
#include "envoy/registry/registry.h" | ||
#include "envoy/server/filter_config.h" | ||
|
||
#include "source/common/buffer/buffer_impl.h" | ||
#include "source/common/router/string_accessor_impl.h" | ||
#include "source/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 { | ||
|
||
class EncoderRecreateStreamFilter : public Http::PassThroughFilter { | ||
public: | ||
constexpr static char name[] = "encoder-recreate-stream-filter"; | ||
|
||
Http::FilterHeadersStatus encodeHeaders(Http::ResponseHeaderMap&, bool) override { | ||
const auto* filter_state = | ||
decoder_callbacks_->streamInfo().filterState()->getDataReadOnly<Router::StringAccessorImpl>( | ||
"test_key"); | ||
|
||
if (filter_state != nullptr) { | ||
return ::Envoy::Http::FilterHeadersStatus::Continue; | ||
} | ||
|
||
decoder_callbacks_->streamInfo().filterState()->setData( | ||
"test_key", std::make_unique<Router::StringAccessorImpl>("test_value"), | ||
StreamInfo::FilterState::StateType::ReadOnly, StreamInfo::FilterState::LifeSpan::Request); | ||
|
||
if (decoder_callbacks_->recreateStream(nullptr)) { | ||
return ::Envoy::Http::FilterHeadersStatus::StopIteration; | ||
} | ||
|
||
return ::Envoy::Http::FilterHeadersStatus::Continue; | ||
} | ||
|
||
void setDecoderFilterCallbacks(Http::StreamDecoderFilterCallbacks& callbacks) override { | ||
decoder_callbacks_ = &callbacks; | ||
} | ||
}; | ||
|
||
// perform static registration | ||
constexpr char EncoderRecreateStreamFilter::name[]; | ||
static Registry::RegisterFactory<SimpleFilterConfig<EncoderRecreateStreamFilter>, | ||
Server::Configuration::NamedHttpFilterConfigFactory> | ||
register_; | ||
|
||
} // namespace Envoy |