envoyproxy / envoyproxy/envoy

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

Open
#11,648 11 comments 2 reactions 1 assignee Claimed by @rulex123 View on GitHub
area/http enhancement help wanted
Dominant language
C++
Stars
28.9k
Forks
5.6k
Avg merge
1d 20h
Merged PRs (30d)
437

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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.