Skip to content

Allow decompression to continue after exceeding max_length - #11966

Merged
Dreamsorcerer merged 222 commits into
masterfrom
Dreamsorcerer-patch-5
Apr 12, 2026
Merged

Dreamsorcerer merged 222 commits into
masterfrom
Dreamsorcerer-patch-5

Conversation

@Dreamsorcerer

@Dreamsorcerer Dreamsorcerer commented Jan 15, 2026 •

Copy link
Copy Markdown
Member

Architecture summary:

  • Compression utils now have a .data_available attribute, when True the decompress() call can be repeated with b"" to get more data. The decompression output has been reduced to 256KiB, matching the socket read limit.
  • DeflateBuffer/StreamReader.feed_data() now return True if there is more data available by calling the method again with b"".
  • (PY) PayloadParser.feed_data() now returns an enum indicating when the payload is complete or whether more input is needed to continue producing output.
  • (PY) HttpParser.feed_data() now returns early when the payload parser is paused and has a new attribute to track if more data is available from the payload parser.
  • (C) HttpParser.cb_on_body() now processes the decompressed data in chunks and pauses llhttp if the parser is asked to pause.
  • (C) HttpParser.feed_data() now call cb_on_body() again when more data is available.
  • Both parsers now have a .pause_reading() method to stop the parser from producing more output.
  • BaseProtocol.pause_reading() now calls the parser's .pause_reading() method.
  • BaseProtocol.resume_reading() now resumes parsing and then checks if it's been paused again before telling the transport to resume.

@Dreamsorcerer Dreamsorcerer added backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot bot:chronographer:skip This PR does not need to include a change note labels Jan 15, 2026
Comment thread tests/test_http_parser.py Resolved
Comment thread tests/test_http_parser.py Resolved
Comment thread tests/test_http_parser.py Resolved
Comment thread tests/test_http_parser.py Resolved
@codecov

codecov Bot commented Jan 15, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.44649% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.92%. Comparing base (b5f1aa5) to head (293d7f6).
⚠️ Report is 531 commits behind head on master.

Files with missing lines Patch % Lines
aiohttp/web_protocol.py 83.33% 1 Missing and 1 partial ⚠️
aiohttp/_http_parser.pyx 98.52% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11966      +/-   ##
==========================================
+ Coverage   98.89%   98.92%   +0.02%     
==========================================
  Files         133      133              
  Lines       46257    46550     +293     
  Branches     2405     2423      +18     
==========================================
+ Hits        45746    46048     +302     
+ Misses        379      373       -6     
+ Partials      132      129       -3     
Flag Coverage Δ
CI-GHA 98.98% <99.36%> (+0.02%) ⬆️
OS-Linux 98.72% <99.36%> (+0.01%) ⬆️
OS-Windows 96.98% <98.94%> (+0.01%) ⬆️
OS-macOS 97.88% <99.15%> (+0.41%) ⬆️
Py-3.10.11 97.39% <94.72%> (+1.11%) ⬆️
Py-3.10.20 97.86% <94.72%> (+0.09%) ⬆️
Py-3.11.15 98.11% <98.73%> (+0.67%) ⬆️
Py-3.11.9 97.65% <98.73%> (+1.16%) ⬆️
Py-3.12.10 97.73% <98.52%> (+<0.01%) ⬆️
Py-3.12.13 98.20% <98.52%> (-0.01%) ⬇️
Py-3.13.12 98.45% <98.73%> (+0.68%) ⬆️
Py-3.14.3 98.50% <97.25%> (+1.69%) ⬆️
Py-3.14.4t 97.51% <97.46%> (+<0.01%) ⬆️
Py-pypy3.11.15-7.3.21 97.34% <93.24%> (?)
VM-macos 97.88% <99.15%> (+0.41%) ⬆️
VM-ubuntu 98.72% <99.36%> (+0.01%) ⬆️
VM-windows 96.98% <98.94%> (+0.01%) ⬆️
cython-coverage 38.21% <78.04%> (+0.40%) ⬆️

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

codspeed Bot commented Jan 15, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 45.32%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 5 improved benchmarks
❌ 3 (👁 3) regressed benchmarks
✅ 53 untouched benchmarks
⏩ 4 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_one_hundred_get_requests_iter_chunks_on_10mb_chunked_payload[pyloop] 1.2 s 1.1 s +8.5%
👁 test_get_request_with_251308_compressed_chunked_payload[zlib_ng.zlib_ng-pyloop] 207 ms 244.4 ms -15.32%
👁 test_get_request_with_251308_compressed_chunked_payload[isal.isal_zlib-pyloop] 62.1 ms 113.5 ms -45.32%
⚡ test_one_thousand_round_trip_websocket_binary_messages[pyloop-large] 110.6 ms 101.7 ms +8.7%
⚡ test_read_large_binary_websocket_messages[pyloop] 8,940.3 µs 49 µs ×180
⚡ test_ten_streamed_responses_iter_chunks[pyloop] 131.5 ms 119.6 ms +9.9%
⚡ test_ten_streamed_responses_iter_chunked_1mb[pyloop] 1.2 s 1.1 s +10.11%
👁 test_ten_streamed_responses_iter_chunked_4096[pyloop] 28.2 ms 35.5 ms -20.68%

Comparing Dreamsorcerer-patch-5 (293d7f6) with master (b5f1aa5)

Open in CodSpeed

Footnotes

  1. 4 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. ↩

Comment thread tests/test_http_parser.py Resolved
@Dreamsorcerer Dreamsorcerer changed the title Test chunk splits after pause Allow decompression to continue after exceeding max_length Jan 15, 2026
Comment thread aiohttp/_http_parser.pyx Resolved
@Dreamsorcerer
Dreamsorcerer merged commit 0c7ce34 into master Apr 12, 2026
44 checks passed
@Dreamsorcerer
Dreamsorcerer deleted the Dreamsorcerer-patch-5 branch April 12, 2026 18:23
@patchback

patchback Bot commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

Backport to 3.14: 💔 cherry-picking failed — conflicts found

❌ Failed to cleanly apply 0c7ce34 on top of patchback/backports/3.14/0c7ce3485dbcda196e125b4ea913a67e6b54f26c/pr-11966

Backporting merged PR #11966 into master

  1. Ensure you have a local repo clone of your fork. Unless you cloned it
    from the upstream, this would be your origin remote.
  2. Make sure you have an upstream repo added as a remote too. In these
    instructions you'll refer to it by the name upstream. If you don't
    have it, here's how you can add it:
    $ git remote add upstream https://github.com/aio-libs/aiohttp.git
  3. Ensure you have the latest copy of upstream and prepare a branch
    that will hold the backported code:
    $ git fetch upstream
    $ git checkout -b patchback/backports/3.14/0c7ce3485dbcda196e125b4ea913a67e6b54f26c/pr-11966 upstream/3.14
  4. Now, cherry-pick PR Allow decompression to continue after exceeding max_length #11966 contents into that branch:
    $ git cherry-pick -x 0c7ce3485dbcda196e125b4ea913a67e6b54f26c
    If it'll yell at you with something like fatal: Commit 0c7ce3485dbcda196e125b4ea913a67e6b54f26c is a merge but no -m option was given., add -m 1 as follows instead:
    $ git cherry-pick -m1 -x 0c7ce3485dbcda196e125b4ea913a67e6b54f26c
  5. At this point, you'll probably encounter some merge conflicts. You must
    resolve them in to preserve the patch from PR Allow decompression to continue after exceeding max_length #11966 as close to the
    original as possible.
  6. Push this branch to your fork on GitHub:
    $ git push origin patchback/backports/3.14/0c7ce3485dbcda196e125b4ea913a67e6b54f26c/pr-11966
  7. Create a PR, ensure that the CI is green. If it's not — update it so that
    the tests and any other checks pass. This is it!
    Now relax and wait for the maintainers to process your pull request
    when they have some cycles to do reviews. Don't worry — they'll tell you if
    any improvements are necessary when the time comes!

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Dreamsorcerer added a commit that referenced this pull request Apr 12, 2026
Dreamsorcerer added a commit that referenced this pull request Apr 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants