envoyproxy/envoy

[Feature Request] Support adding response flags and response code details in custom response headers

Open

#11,648 opened on Jun 18, 2020

View on GitHub
 (11 comments) (2 reactions) (1 assignee)C++ (5,373 forks)batch import
area/httpenhancementhelp wanted

Repository metrics

Stars
 (27,997 stars)
PR merge metrics
 (Avg merge 8d) (378 merged PRs in 30d)

Description

Description: Envoy supports adding a set of custom request/response headers and also dynamic values in those headers. By adding headers with RESPONSE_CODE_DETAILS and RESPONSE_FLAGS, we provide additional context to clients whether the response code has come from Envoy or the upstream backend, as well as why the request has failed.

Envoy currently has some support for RESPONSE_CODE_DETAILS and RESPONSE_FLAGS as custom headers, but we observed that in cases where the Envoy sidecar sends a local 503 response, for example, when there are no healthy upstreams, custom headers are not getting added to the responses. Investigating the issue, we noticed that finalizeResponseHeaders are not called when the Envoy Router sendLocalReply.

callbacks_->sendLocalReply(Http::Code::ServiceUnavailable, "no healthy upstream", modify_headers_, absl::nullopt, StreamInfo::ResponseCodeDetails::get().NoHealthyUpstream);

A possible solution might be to call finalizeResponseHeaders in modify_headers_ for cases that Envoy sends a local reply.

[optional Relevant Links:] Custom request/response header Envoy doc: https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_conn_man/headers#custom-request-response-headers https://www.envoyproxy.io/docs/envoy/latest/configuration/observability/access_log/usage#config-access-log-format-response-flags

Contributor guide