feat(decompress): add preserveHeaders option #6239
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 215 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.322
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #6239"
general
weight: 0.35
mcollina
Add a preserveHeaders option, defaulting to false. When enabled, keep Content-Encoding and Content-Length in both normalized headers and controller.rawHeaders while still decompressing the response body.
This allows jsdom to reuse the interceptor for XMLHttpRequest, whose response headers describe the encoded response even though its body is decoded.
<!--
Before submitting a Pull Request, please read our contribution guidelines, which
can be found at CONTRIBUTING.md in the repository root.
For code changes:
1. Include tests for any bug fixes or new features.
2. Update documentation if relevant.
3. Ensure that tests and linting pass.
You will also need to ensure that your contribution complies with the
Developer's Certificate of Origin, outlined in CONTRIBUTING.md
-->
This relates to...
#6046 and https://github.com/jsdom/jsdom/pull/4469.
Rationale
I’d like jsdom to reuse undici’s decompression interceptor for XMLHttpRequest, which exposes the original response headers alongside the decoded body. Currently, doing so requires an adapter to capture and restore the headers.
Changes
Features
Add a
preserveHeadersoption that retainsContent-EncodingandContent-Lengthin both response headers andcontroller.rawHeaderswhile decompressing the body. It defaults tofalse, preserving existing behavior.Bug Fixes
N/A.
Breaking Changes and Deprecations
None.
Status
[cert]: https://github.com/nodejs/undici/blob/main/CONTRIBUTING.md#developers-certificate-of-origin