-
Notifications
You must be signed in to change notification settings - Fork 606
Description
Description:
My use case is that I want to add a response header only if the header is not present in the response.
For example, if the backend defines a CSP header, I want to keep that one, but if no such header is defined, I want to send a default one in the gateway.
With the ClientTrafficPolicy v1.6 there are three options for late response header modification:
add: appends the header if present, or adds the header when absentset: overwrite the header if present, or adds the header when absentremove: delete the given header from the response
With these options, the "only add if absent" case is not supported.
Envoy proxy supports this use-case with the ADD_IF_ABSENT action.
To not break the Spec, I could imagine extending the ClientTrafficPolicySpec HeaderSettings with a fourth field like preserve or addOrPreserve which then uses the ADD_IF_ABSENT action.
If a spec change can be considered, I'd map the add section to the ADD_IF_ABSENT action and create a new one append that maps to APPEND_IF_EXISTS_OR_ADD. However, I don't like this approach, as this contradicts the GatewayAPI spec HttpRouteFilter ResponseHeaderModifier.
Relevant Links: