envoyproxy / envoyproxy/envoy

Ability to rename request headers

Offen
#8,947 2 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
api/v3 design proposal help wanted
Vorherrschende Sprache
C++
Sterne
28.9k
Forks
5.6k
Ø Merge
1 T. 22 Std.
Gemergte PRs (30 T.)
430

Beschreibung

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 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?

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.