Skip to content

fix: decode multiple Content-Encoding codings in reverse order (RFC 9110) - #13377

Open
waterWang wants to merge 1 commit into
aio-libs:masterfrom
waterWang:fix/content-encoding-multi-coding
Open

fix: decode multiple Content-Encoding codings in reverse order (RFC 9110)#13377
waterWang wants to merge 1 commit into
aio-libs:masterfrom
waterWang:fix/content-encoding-multi-coding

Conversation

@waterWang

Copy link
Copy Markdown

Summary

RFC 9110 §8.4 allows Content-Encoding to list multiple codings. The client must decode them in reverse order. When a server sends a body compressed twice with Content-Encoding: gzip,gzip, aiohttp currently does not decode the body because the header value "gzip,gzip" does not match the single-coding set {"gzip", "deflate", "br", "zstd"}.

Changes

  1. HttpParser.parse_headers() — Parse Content-Encoding as a comma-separated list. Validate each coding individually and store the normalized list as a comma-separated string (e.g., "gzip,gzip").

  2. HttpPayloadParser.__init__() — Chain multiple DeflateBuffer instances in reverse order so each coding is decoded in the correct sequence (last applied first).

  3. DeflateBuffer.__init__() — Forward _low_water from the wrapped stream to support safe chaining of DeflateBuffer instances.

Testing

Expected: {"hello": "world"} when the endpoint sends Content-Encoding: gzip,gzip with a doubly-gzipped JSON body.

Fixes #13364

@waterWang
waterWang requested a review from asvetlov as a code owner August 10, 2026 11:16
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.99%. Comparing base (b2b7b50) to head (5371160).
⚠️ Report is 32 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #13377    +/-   ##
========================================
  Coverage   98.98%   98.99%            
========================================
  Files         132      132            
  Lines       49023    49297   +274     
  Branches     2551     2568    +17     
========================================
+ Hits        48526    48802   +276     
+ Misses        373      371     -2     
  Partials      124      124            
Flag Coverage Δ
Autobahn 22.06% <9.09%> (-0.07%) ⬇️
CI-GHA 98.90% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.68% <100.00%> (+<0.01%) ⬆️
OS-Windows 97.03% <100.00%> (+<0.01%) ⬆️
OS-macOS 97.93% <100.00%> (-0.01%) ⬇️
Py-3.10 98.12% <100.00%> (+0.01%) ⬆️
Py-3.11 98.38% <100.00%> (+<0.01%) ⬆️
Py-3.12 98.47% <100.00%> (+<0.01%) ⬆️
Py-3.13 98.45% <100.00%> (+<0.01%) ⬆️
Py-3.14 98.47% <100.00%> (+0.01%) ⬆️
Py-3.14t 97.56% <100.00%> (-0.01%) ⬇️
Py-pypy-3.11 97.40% <100.00%> (+0.01%) ⬆️
VM-macos 97.93% <100.00%> (-0.01%) ⬇️
VM-ubuntu 98.68% <100.00%> (+<0.01%) ⬆️
VM-windows 97.03% <100.00%> (+<0.01%) ⬆️
cython-coverage 38.14% <100.00%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@codspeed-hq

codspeed-hq Bot commented Aug 10, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 84 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing waterWang:fix/content-encoding-multi-coding (5371160) with master (b084084)2

Open in CodSpeed

Footnotes

  1. 83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on master (b1e47ae) during the generation of this report, so b084084 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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.

Content-Encoding with multiple codings is not decoded

1 participant