Support JSON error response bodies#13415
Open
bneradt wants to merge 1 commit into
Open
Conversation
bneradt
force-pushed
the
header-rewrite-json-bodies
branch
from
July 21, 2026 20:16
c2e2428 to
857086d
Compare
ATS cannot reliably emit JSON error responses through header rewrite: literal bodies cannot select a MIME type, HRW4U treats JSON braces as interpolation, fetched bodies lose their Content-Type, and conditional local files are unavailable. Body factory error pages are also hardcoded to HTML. This adds optional Content-Type arguments to set-body and set-body-from, preserves fetched response types, adds configuration-time local file bodies, and teaches HRW4U literal JSON braces and MIME-aware forms. It also adds body-factory Content-Type metadata and clears stale MIME state for empty fabricated bodies. Network set-body-from remains READ_RESPONSE-only because remap hooks cannot suspend for its asynchronous fetch. This covers remap-time errors with literal or file-backed bodies instead. This incorporates Bryan Call's body-factory work from apache#12947. Related: apache#10893 Fixes: apache#13393 Fixes: apache#11480 Co-authored-by: Bryan Call <bcall@apache.org>
bneradt
force-pushed
the
header-rewrite-json-bodies
branch
from
July 21, 2026 21:15
857086d to
a791484
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
ATS cannot reliably emit JSON error responses through header rewrite: literal bodies cannot select a MIME type, HRW4U interprets JSON braces as interpolation, fetched bodies lose their Content-Type, and conditional local files are unavailable. Body factory error pages are also hardcoded to HTML.
Changes
set-bodyandset-body-from.set-body-from-file, loaded once at rule-configuration time.The asynchronous URL form remains
READ_RESPONSE-only because remap callbacks cannot suspend for an internal fetch. REMAP errors are handled by the literal or file-backed forms without origin or cache lookup.This includes the body-factory work from #12947 and preserves Bryan Call's original commits.
Related: #10893
Fixes: #13393
Fixes: #11480