{{ message }}
Repository navigation
Accept case-insensitive range unit names in http_range - #13581
Merged
Dreamsorcerer merged 3 commits intoAug 31, 2026
Merged
Conversation
Range unit names are case-insensitive per RFC 9110 section 14.1.1. The previous regex only matched lowercase 'bytes', so valid headers like 'Range: Bytes=0-499' raised ValueError and made FileResponse return 416 for satisfiable ranges.
Merging this PR will not alter performance
Comparing Footnotes
|
Manny7717
marked this pull request as ready for review
August 29, 2026 04:19
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "Apply batched suggestions from code revi..." | Re-trigger Greptile |
Co-authored-by: Sam Bull <aa6bs0@sambull.org>
Contributor
Backport to 3.15: 💚 backport PR created✅ Backport PR branch: Backported as #13588 🤖 @patchback |
Merged
5 tasks done
Contributor
Merged
5 tasks done
Dreamsorcerer
pushed a commit
that referenced
this pull request
Aug 31, 2026
Dreamsorcerer
pushed a commit
that referenced
this pull request
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What do these changes do?
BaseRequest.http_rangenow matches the range unit name case-insensitively (re.IGNORECASE), per RFC 9110 §14.1.1 ("All range unit names are case-insensitive").Previously a valid header like
Range: Bytes=0-499failed the^bytes=(\d*)-(\d*)$regex, raisingValueError("range not in acceptable format"), whichFileResponseconverts into416 Requested Range Not Satisfiable— even for a perfectly satisfiable range. Only lowercasebytes=worked.Are there changes in behavior for the user?
Yes, for the better: case variants of the range unit (
Bytes,BYTES,bYtEs, …) are now accepted and yield206 Partial Contentwhere lowercase already did. Behavior for lowercasebytes=and for genuinely malformed ranges (non-bytesunits, non-numeric bounds, multi-range, empty) is unchanged — those still raise the sameValueError.Is it a substantial burden for the maintainers to support this?
No. One regex flag; no API surface change; the pure-Python
http_rangeproperty is the only code path touched.FileResponseconsumes it, so the fix propagates automatically.Related issue number
Fixes #13580
Checklist
CONTRIBUTORS.txtCHANGES/folder<issue_or_pr_num>.<type>.rst(e.g.588.bugfix.rst).bugfix: A bug fix for something the maintainers deemed an improper undesired behavior that got corrected to match pre-agreed expectations.Test output
(10 of those are the
http_range/range parsing tests, including the newtest_range_to_slice_uppercase_unit.)End-to-end repro (local
web.FileResponseserver, raw TCP requests):Drafted with Hermes Agent (deepseek-v4-flash); reviewed by Manny7717.