Skip to content

response header manipulation for DirectResponseAction #3520

@derekargueta

Description

@derekargueta

Title: header manipulation for DirectResponseAction

Description:
Our goal here is when we return an HTML file in a DirectResponseAction (i.e. a Forbidden page), to have it's content-type set to text/html. By default it's text/plain, rendering incorrectly in the browser. This could be done by setting the content-type response header but there is no way to specify response headers for just a DirectResponseAction that I can identify (proto struct). Another solution is to have Envoy infer the content-type for DirectResponseActions using the filesystem.

Currently, response headers can be modified at 1) the entire route configuration (doc), 2) the virtual host level (doc), or 3) in a single RouteAction (doc) which doesn't cover DirectResponseAction since they are "side-by-side".

Potential steps to resolve this are either

  1. move the response_headers_to_add options from the RouteAction to the Route so that these options can apply regardless if the action is a RouteAction, DirectResponseAction, RedirectAction or any other future actions (preferred IMO but breaks the API)
  2. Add response_headers_to_add options to DirectResponseAction, (and potentially) RedirectAction, and other future actions
  3. Support the ability to detect content-type for DirectResponseAction based on filename extension if loading from file (easy but only solves a very narrow use-case, in this case ours)

This isn't a strict requirement we have to meet, but a feature that would be useful.

cc @rgs1 @brian-pane

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFeature requests. Not bugs or questions.help wantedNeeds help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions