Skip to content

Handle satisfiable multi-range requests in FileResponse - #14174

Open
emadleo13 wants to merge 6 commits into
aio-libs:masterfrom
emadleo13:test-14124-multirange
Open

emadleo13 wants to merge 6 commits into
aio-libs:masterfrom
emadleo13:test-14124-multirange

Conversation

@emadleo13

@emadleo13 emadleo13 commented Oct 26, 2026 •

Copy link
Copy Markdown

What do these changes do?

Handle valid, satisfiable multi-range requests in FileResponse
by ignoring the Range header and serving the full file with HTTP 200.

Preserve HTTP 416 for malformed and wholly unsatisfiable ranges,
and HTTP 206 for valid single-range requests.

Added regression tests, documentation, changelog, and contributor entry.

Are there changes in behavior for the user?

Yes. Valid multi-range requests that previously returned 416
now receive 200 with the complete file.

Is it a substantial burden for the maintainers to support this?

The fix is limited to FileResponse and adds no public API.

Related issue number

Fixes #14124.

This is an independently developed alternative to #14129.
It includes additional regression coverage for whitespace,
reversed ranges, and wholly unsatisfiable range sets.
I am open to coordinating the changes.

Checklist

  • Unit tests for the changes exist
  • Documentation reflects the changes
  • Added entry to CONTRIBUTORS.txt
  • Added changelog fragment
  • Final human review before marking ready

Verification

  • 18 focused regression tests passed
  • 209 FileResponse tests passed
  • Pre-commit checks passed
  • Full repository suite not yet run

@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Oct 26, 2026
Comment thread aiohttp/web_fileresponse.py Fixed
@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.11%. Comparing base (3df45d9) to head (9346dcd).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #14174   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         135      135           
  Lines       53338    53401   +63     
  Branches     2717     2726    +9     
=======================================
+ Hits        52865    52930   +65     
+ Misses        359      358    -1     
+ Partials      114      113    -1     
Flag Coverage Δ
Autobahn 21.68% <9.09%> (-0.02%) ⬇️
CI-GHA 99.04% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.68% <100.00%> (+<0.01%) ⬆️
OS-Windows 97.49% <100.00%> (+0.01%) ⬆️
OS-macOS 98.34% <100.00%> (-0.01%) ⬇️
Py-3.11 98.30% <100.00%> (+0.01%) ⬆️
Py-3.12 98.37% <100.00%> (+<0.01%) ⬆️
Py-3.13 98.36% <100.00%> (-0.01%) ⬇️
Py-3.14 98.39% <100.00%> (-0.01%) ⬇️
Py-3.15 98.39% <100.00%> (+<0.01%) ⬆️
Py-3.15t 98.24% <100.00%> (+<0.01%) ⬆️
Py-pypy-3.12 96.94% <100.00%> (+<0.01%) ⬆️
VM-macos-latest 98.34% <100.00%> (-0.01%) ⬇️
VM-ubuntu-latest 98.68% <100.00%> (+<0.01%) ⬆️
VM-windows-latest 97.49% <100.00%> (+0.01%) ⬆️
cython-coverage 83.70% <21.05%> (-0.10%) ⬇️

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 Oct 26, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 49 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 102 untouched benchmarks
⏩ 83 skipped benchmarks1


Comparing emadleo13:test-14124-multirange (9346dcd) with master (3df45d9)

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

@emadleo13
emadleo13 marked this pull request as ready for review October 26, 2026 22:57
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Reviews (3) · Last reviewed commit: "Merge branch 'master' into test-14124-mu..." · Reviewed by Greptile

Comment thread aiohttp/web_fileresponse.py Resolved
@emadleo13

Copy link
Copy Markdown
Author

Hello maintainers,
i reviewed the CI results for this PR. All checks are passing except "Backport label added" (51/52), which appears to require a backport label.
could you please advise which backport label is appropriate for this change, or apply it if this is managed by maintainers?
i am also aware of PR #14129, which addresses the same issue (#14124). I'm happy to coordinate or adjust my implementation based on your preferred approach.
Thank you for your time and review

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

FileResponse answers a satisfiable multi-range request with 416

2 participants