Skip to content

router: fix direct_response Content-Type#43694

Merged
wbpcode merged 4 commits intoenvoyproxy:mainfrom
garimauttam:fix/direct-response-content-type
Mar 5, 2026
Merged

router: fix direct_response Content-Type#43694
wbpcode merged 4 commits intoenvoyproxy:mainfrom
garimauttam:fix/direct-response-content-type

Conversation

@garimauttam
Copy link
Contributor

Problem

When direct_response uses body_format.content_type, the response always returns Content-Type: text/plain. The field was parsed from proto but never stored or applied.

Fix

  • Added responseContentType() pure virtual to DirectResponseEntry
  • Stored content_type from body_format in RouteEntryImplBase (explicit → JSON default → empty)
  • Applied it in the sendLocalReply modify_headers lambda

Tests added

  • RouteConfigurationV2.DirectResponseBodyFormatContentType — all 4 content-type cases
  • RouterTest.DirectResponseWithBodyFormatContentType — end-to-end text/html header
  • RouterTest.DirectResponseWithBodyFormatNoContentType — no override when empty

Fixes #43680

ravenblackx
ravenblackx previously approved these changes Mar 3, 2026
Copy link
Contributor

@ravenblackx ravenblackx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good fix to me, thanks!

Signed-off-by: garima-uttam <garimauttam@ibm.com>
Signed-off-by: garima-uttam <garimauttam@ibm.com>
@ravenblackx
Copy link
Contributor

In general please try to avoid force pushing as it makes reviewing more work - append commits rather than amending.

Autoformatter now requires a fix, see this CI run.

Signed-off-by: garima-uttam <garimauttam@ibm.com>
@ravenblackx
Copy link
Contributor

/retest

@ravenblackx
Copy link
Contributor

/assign-from @envoyproxy/senior-maintainers

@repokitteh-read-only
Copy link

@envoyproxy/senior-maintainers assignee is @phlax

🐱

Caused by: a #43694 (comment) was created by @ravenblackx.

see: more, trace.

@phlax
Copy link
Member

phlax commented Mar 4, 2026

lgtm, but probs im not the senior maintainer needed for sign off

/retest

@ravenblackx
Copy link
Contributor

/retest

Copy link
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks.

@wbpcode wbpcode merged commit c4dd88c into envoyproxy:main Mar 5, 2026
29 checks passed
@garimauttam garimauttam deleted the fix/direct-response-content-type branch March 5, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

direct_response: Content-Type is always text/plain and ignores body_format config

4 participants