-
Notifications
You must be signed in to change notification settings - Fork 5.3k
response header manipulation for DirectResponseAction #3520
Description
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
- move the
response_headers_to_addoptions from theRouteActionto theRouteso that these options can apply regardless if the action is aRouteAction,DirectResponseAction,RedirectActionor any other future actions (preferred IMO but breaks the API) - Add
response_headers_to_addoptions toDirectResponseAction, (and potentially)RedirectAction, and other future actions - Support the ability to detect content-type for
DirectResponseActionbased 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