Headers transforms support RegEx
What should we add or change to make your life better?
There are header transforms that allow to remove a specific header or allow specific headers. E.g. RequestHeaderRemove, ResponseHeaderRemove, ResponseHeadersAllowed etc. In cases when I need to remove or allow multiple headers with similar names it would be more convenient to use RegEx.
Why is this important to you?
I need to remove multiple similar headers from a proxied response. E.g. "x-foo-a", "x-foo-b" etc. Now I need to list them one by one either I use ResponseHeaderRemove or ResponseHeadersAllowed.
Some thoughts on how it can look like:
- Keep RequestHeaderRemove/ResponseHeaderRemove as is because of their singular name.
- Introduce RequestHeadersRemove/ResponseHeadersRemove transforms. Example format:
| Key | Value | Default | Required |
|---|---|---|---|
| RequestHeadersRemove | RegEx expression | (none) | yes |
| When | Success/Always/Failure | Success | no |
- RequestHeadersAllowed/ResponseHeadersAllowed already expect a comma separated list of headers. Since header names don't contain special symbols could possibly allow to pass RegEx here. The implementation will check the value passed if it is RegEx or not. Another options would be 3.1. Add another key to switch between the comma separated list and RegEx, e.g. UseRegex: true/false. 3.2. Leave RequestHeadersAllowed/ResponseHeadersAllowed as is and introduce new transforms like RequestHeadersAllowedRegex/ResponseHeadersAllowedRegex/RequestHeadersRemoveRegex/ResponseHeadersRemoveRegex.
Triage: It should be doable today in custom transforms. We could do it in config, but it comes with complexity of escaping. Given that we would like to see if there is more demand for feature like this -- please upvote top post if you come across this and are interested in the feature. That will help us prioritize. Thanks!