-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Implement request header processing in ext_proc #14385
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 2 commits
5086541
66faf2d
611ec4d
70cefbb
48fe856
ae1d84c
ab66de1
721af9c
f086d09
47cdf80
dbad315
636b488
47691db
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 |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| #include "extensions/filters/http/ext_proc/headers.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace HttpFilters { | ||
| namespace ExternalProcessing { | ||
|
|
||
| using Http::LowerCaseString; | ||
|
|
||
| void buildHttpHeaders(const Http::HeaderMap& headers_in, | ||
|
gbrail marked this conversation as resolved.
Outdated
|
||
| envoy::config::core::v3::HeaderMap* headers_out) { | ||
|
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. Nit: Envoy style prefers mutable refs, e.g.
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. Yes, fixed that. |
||
| headers_in.iterate([headers_out](const Http::HeaderEntry& e) -> Http::HeaderMap::Iterate { | ||
| auto new_header = headers_out->add_headers(); | ||
|
gbrail marked this conversation as resolved.
Outdated
|
||
| new_header->set_key(std::string(e.key().getStringView())); | ||
| new_header->set_value(std::string(e.value().getStringView())); | ||
| return Http::HeaderMap::Iterate::Continue; | ||
|
gbrail marked this conversation as resolved.
Outdated
|
||
| }); | ||
| } | ||
|
htuch marked this conversation as resolved.
Outdated
|
||
|
|
||
| void applyHeaderMutations(const envoy::service::ext_proc::v3alpha::HeaderMutation& mutation, | ||
| Http::HeaderMap* headers) { | ||
| for (const auto& sh : mutation.set_headers()) { | ||
| if (!sh.has_header()) { | ||
| continue; | ||
| } | ||
| bool append = false; | ||
| if (sh.has_append()) { | ||
| append = sh.append().value(); | ||
| } | ||
| if (append) { | ||
| headers->addCopy(LowerCaseString(sh.header().key()), sh.header().value()); | ||
| } else { | ||
| headers->setCopy(LowerCaseString(sh.header().key()), sh.header().value()); | ||
| } | ||
| } | ||
|
|
||
| for (const auto& rh : mutation.remove_headers()) { | ||
| headers->remove(LowerCaseString(rh)); | ||
| } | ||
| } | ||
|
|
||
| } // namespace ExternalProcessing | ||
| } // namespace HttpFilters | ||
| } // namespace Extensions | ||
| } // namespace Envoy | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #pragma once | ||
|
|
||
| #include "envoy/http/header_map.h" | ||
| #include "envoy/service/ext_proc/v3alpha/external_processor.pb.h" | ||
|
|
||
| namespace Envoy { | ||
| namespace Extensions { | ||
| namespace HttpFilters { | ||
| namespace ExternalProcessing { | ||
|
|
||
| extern void buildHttpHeaders(const Http::HeaderMap& headers_in, | ||
| envoy::config::core::v3::HeaderMap* headers_out); | ||
|
|
||
| extern void applyHeaderMutations(const envoy::service::ext_proc::v3alpha::HeaderMutation& mutation, | ||
| Http::HeaderMap* headers); | ||
|
|
||
| } // namespace ExternalProcessing | ||
| } // namespace HttpFilters | ||
| } // namespace Extensions | ||
| } // namespace Envoy |
Uh oh!
There was an error while loading. Please reload this page.