Skip to content

[v7.x] fix(decompress): join a repeated content-encoding header (#5664) - #6026

Merged
mcollina merged 1 commit into
nodejs:v7.xfrom
mrityunjay-pandey:backport/v7.x-decompress-repeated-encoding
Oct 17, 2026
Merged

mcollina merged 1 commit into
nodejs:v7.xfrom
mrityunjay-pandey:backport/v7.x-decompress-repeated-encoding

Conversation

@mrityunjay-pandey

Copy link
Copy Markdown
Contributor

This relates to...

Backport of #5664 to v7.x.

Rationale

On v7.x, a response that repeats the Content-Encoding header reaches the decompress interceptor as an array, and onResponseStart calls toLowerCase() on it. With the test from #5664 applied to v7.x, the request fails with TypeError: contentEncoding.toLowerCase is not a function.

Changes

  • Cherry-pick of a975197 (git cherry-pick -x). lib/interceptor/decompress.js applied cleanly. The test file only conflicted because v7.x has extra tests at the end of the file, so the new test is appended after them unchanged.

Note: #6024 also appends a test at the end of test/interceptors/decompress.js, so whichever of the two lands second needs a trivial rebase. I'll take care of it.

Features

N/A

Bug Fixes

  • The decompress interceptor joins repeated Content-Encoding field lines (RFC 9110 section 5.3) instead of throwing.

Breaking Changes and Deprecations

N/A

Status

Tested locally on Linux with Node 24: node --test test/interceptors/decompress.js (46 pass), npm run lint and npm run test:unit (1324 tests, 1321 pass, 3 skipped, 0 fail).

parseHeaders turns a repeated field into an array, and this method's own
JSDoc already types the headers record as string | string[] | undefined.
An array is truthy, so the skip check let it through and toLowerCase threw
a TypeError.

RFC 9110 section 5.3 allows joining repeated field lines with commas, which
produces the single-line form the decompression chain already splits and
handles, including the maxContentEncodings guard.

(cherry picked from commit a975197)
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 93.16%. Comparing base (7d60c7b) to head (e523ed4).

Additional details and impacted files
@@           Coverage Diff           @@
##             v7.x    #6026   +/-   ##
=======================================
  Coverage   93.15%   93.16%           
=======================================
  Files         112      112           
  Lines       37626    37632    +6     
=======================================
+ Hits        35052    35058    +6     
  Misses       2574     2574           

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

5 participants