Accept case-insensitive range unit names in Range header - #13585
Accept case-insensitive range unit names in Range header#13585afonsojanu wants to merge 1 commit into
Conversation
RFC 9110 section 14.1.1 states that range unit names are case-insensitive, but the regex used to parse the Range header only matched a lowercase 'bytes' literal. A request sent with any other casing, such as 'Bytes=0-3' or 'BYTES=0-3', raised a ValueError that FileResponse turned into a 416 response even though the range itself was perfectly valid. Added re.IGNORECASE to the existing pattern match and a regression test covering an uppercase-initial unit name alongside the existing lowercase and non-ASCII cases. Fixes aio-libs#13580
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness, compatibility, or security issues identified. The parser remains anchored to the Reviews (1): Last reviewed commit: "Accept case-insensitive range unit names..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13585 +/- ##
=======================================
Coverage 99.02% 99.02%
=======================================
Files 135 135
Lines 50500 50504 +4
Branches 2652 2652
=======================================
+ Hits 50007 50011 +4
Misses 370 370
Partials 123 123
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will not alter performance
Comparing Footnotes
|
Closes #13580.
RFC 9110 section 14.1.1 states that range unit names are case-insensitive, but the regex used to parse the
Rangeheader only matched a lowercasebytesliteral:A request sent with any other casing, such as
Range: Bytes=0-3orRange: BYTES=0-3, raisedValueError("range not in acceptable format"), whichFileResponseturns into a 416 response even though the range itself is perfectly satisfiable.Added
re.IGNORECASEto the existing pattern match flags and a regression test alongside the existing range-parsing tests, covering an uppercase-initial unit name. Ran the fulltest_web_request.pysuite plus flake8 on the touched files.