Skip to content

Support adding response header if not present in the ClientTrafficPolicy #7656

@funkluk

Description

@funkluk

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 absent
  • set: overwrite the header if present, or adds the header when absent
  • remove: 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions