Métricas do repositório
- Stars
- (27.997 stars)
- Métricas de merge de PR
- (Mesclagem média 8d) (378 fundiu PRs em 30d)
Description
Now that we can use request headers in the request_headers_to_add option, one might want to rename a header:
request_headers_to_remove:
- x-header
request_headers_to_add:
- header:
key: x-new-name
value: "%REQ(x-header)%"
However this will not work, because HeaderParser::evaluateHeaders removes headers first.
void HeaderParser::evaluateHeaders(Http::HeaderMap& headers,
const StreamInfo::StreamInfo& stream_info) const {
// Removing headers in the headers_to_remove_ list first makes
// remove-before-add the default behavior as expected by users.
This was introduced in #5052 : "reverses the order of header evaluation as a solution to deduplicating request/response headers".
There are multiple ways to approach this header-renaming issue.
One is to add request_headers_to_post_remove which will be used after request_headers_to_add.
Another would be request_headers_to_pre_add but "post-remove" is better because headers-to-remove is just a list of names, when headers-to-add is much bulkier.
The most trivial option is to introduce a map<string, string> rename_headers.
There is also an option to add a preserve_request_headers list, to store original request headers somewhere in StreamInfo, and add a new formatter, e.g. %PREQ(header-name)% to access them. It might be useful because such headers won't be removed or modified by filters. However for now I just want to rename a couple of headers and this would be an overkill.
So, how about a new post-remove header list?