-
Notifications
You must be signed in to change notification settings - Fork 5.5k
http: introduce addEncodedMetadata() #7756
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 14 commits
614ba5d
f7b24b3
2d85da4
55375f6
c80b445
bd03a39
b1c22b0
1246b96
5e22128
b464c1d
bc4493a
ac8c0bf
b08fbbe
128dcc7
736f0a1
fbcfe1e
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 |
|---|---|---|
|
|
@@ -164,6 +164,10 @@ void StreamEncoderImpl::encodeData(Buffer::Instance& data, bool end_stream) { | |
|
|
||
| void StreamEncoderImpl::encodeTrailers(const HeaderMap&) { endEncode(); } | ||
|
|
||
| void StreamEncoderImpl::encodeMetadata(const MetadataMapVector&) { | ||
| ENVOY_LOG_MISC(error, "HTTP1 doesn't support metadata"); | ||
|
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. So if an H2 upstream sends medatadata to an H1 data source, we'll log an error message for every frame? I think we want to handle that in a way that's less painful. I think ideally we'd error log once (or better yet with pow-2 backoff) and increment a stat, but I don't think Envoy has backoff logging yet so maybe just a stat for now?
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. Good idea! Fixed in a separate PR.
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. Cool. If you want to change this to a no-op I'd be fine with it landing as-is, though it should probably get a Matt Klein pass as well.
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. Maybe I can sync to master after #7801 is merged?
Member
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 agreed this should be a NOP + stat, so fine to review the other change first and then come back to this one. |
||
| } | ||
|
|
||
| void StreamEncoderImpl::endEncode() { | ||
| if (chunk_encoding_) { | ||
| connection_.buffer().add(LAST_CHUNK); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,42 +16,39 @@ class ResponseMetadataStreamFilter : public Http::PassThroughFilter { | |
| public: | ||
| // Inserts one new metadata_map. | ||
| Http::FilterHeadersStatus encodeHeaders(Http::HeaderMap&, bool) override { | ||
| Http::MetadataMap metadata_map = { | ||
| {"headers", "headers"}, {"duplicate", "duplicate"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"headers", "headers"}, {"duplicate", "duplicate"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
|
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. Are there HCM unit tests we should update as well?
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. I think adding new metadata was only covered in integration test. |
||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterHeadersStatus::Continue; | ||
| } | ||
|
|
||
| // Inserts one new metadata_map. | ||
| Http::FilterDataStatus encodeData(Buffer::Instance&, bool) override { | ||
| Http::MetadataMap metadata_map = { | ||
| {"data", "data"}, {"duplicate", "duplicate"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"data", "data"}, {"duplicate", "duplicate"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterDataStatus::Continue; | ||
| } | ||
|
|
||
| // Inserts two metadata_maps by calling decoder_callbacks_->encodeMetadata() twice. | ||
| Http::FilterTrailersStatus encodeTrailers(Http::HeaderMap&) override { | ||
| Http::MetadataMap metadata_map = {{"trailers", "trailers"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"trailers", "trailers"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| metadata_map = {{"duplicate", "duplicate"}}; | ||
| metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterTrailersStatus::Continue; | ||
| } | ||
|
|
||
| // Inserts two metadata_maps by calling decoder_callbacks_->encodeMetadata() twice. | ||
| Http::FilterHeadersStatus encode100ContinueHeaders(Http::HeaderMap&) override { | ||
| Http::MetadataMap metadata_map = { | ||
| {"100-continue", "100-continue"}, {"duplicate", "duplicate"}, {"remove", "remove"}}; | ||
| Http::MetadataMap metadata_map = {{"100-continue", "100-continue"}, {"duplicate", "duplicate"}}; | ||
| Http::MetadataMapPtr metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| metadata_map = {{"duplicate", "duplicate"}}; | ||
| metadata_map_ptr = std::make_unique<Http::MetadataMap>(metadata_map); | ||
| decoder_callbacks_->encodeMetadata(std::move(metadata_map_ptr)); | ||
| encoder_callbacks_->addEncodedMetadata(std::move(metadata_map_ptr)); | ||
| return Http::FilterHeadersStatus::Continue; | ||
| } | ||
|
|
||
|
|
@@ -66,10 +63,6 @@ class ResponseMetadataStreamFilter : public Http::PassThroughFilter { | |
| metadata_map.erase("consume"); | ||
| metadata_map.emplace("replace", "replace"); | ||
| } | ||
| it = metadata_map.find("remove"); | ||
| if (it != metadata_map.end()) { | ||
| metadata_map.erase("remove"); | ||
| } | ||
| it = metadata_map.find("metadata"); | ||
| if (it != metadata_map.end()) { | ||
| metadata_map.erase("metadata"); | ||
|
|
||
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.
Is this necessary? If so let's use the {nullptr} syntax you use for request_medata_map_vector_
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.
Fixed. Thanks!