-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Title: When using a direct_response route action with body_format (introduced in #41821), the response Content-Type header is always text/plain regardless of the format configuration
Description:
The SubstitutionFormatString API allows setting a content_type, defaulting to text/plain for a text format and applicaton/json for a JSON format. Using this config option in a direct_response route action's body_format will not result in the route's response having the configured Content-Type header. Instead, text/plain is always returned.
Repro steps:
- Configure a route with
direct_responseaction andbody_formatwithcontent_type: "application/json"configured - Make a GET request to that route
- Observe that
Content-Typein the response istext/plain
Config:
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 10000 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: direct_response
domains: ["*"]
routes:
- match: { prefix: "/" }
direct_response:
status: 200
body_format:
content_type: "text/html"
text_format_source:
inline_string: "<strong>Request Path:</strong> %REQ(:path)%"
http_filters:
- name: envoy.filters.http.router
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.RouterI was not sure whether to file this as a bug or a feature request, since the PR implementing this feature (#41821) did not even intend to address this directly. I decided for bug considering that as a user, I generally only see the API surface which does present me with the content_type option.