← Back to Pull requests

feat(decompress): add preserveHeaders option #6239

Closed
unknown closed this pull request without merging on Nov 21, 2026 07:21 UTC
View on GitHub
unknown unknown commented on Nov 21, 2026 06:14 UTC
Author

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 preserveHeaders option that retains Content-Encoding and Content-Length in both response headers and controller.rawHeaders while decompressing the body. It defaults to false, preserving existing behavior.

Bug Fixes

N/A.

Breaking Changes and Deprecations

None.

Status

  • I have read and agreed to the [Developer's Certificate of Origin][cert]

  • Tested

  • Benchmarked (optional)

  • Documented

  • Review ready

  • In review

  • Merge ready
  • [cert]: https://github.com/nodejs/undici/blob/main/CONTRIBUTING.md#developers-certificate-of-origin

    Diff: 215 lines (+161 / -54) across 2 files Reviewer: mcollina Review duration: 67m
    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
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.6% (MEDIUM) · Higher = larger blast radius
    36.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 14.5% · Safe to merge
    14.5%
    Repository