Skip to content

Honor suffix byte ranges larger than the response body - #502

Open
Mirochill wants to merge 1 commit into
Pylons:mainfrom
Mirochill:fix-oversized-suffix-byte-ranges
Open

Mirochill wants to merge 1 commit into
Pylons:mainfrom
Mirochill:fix-oversized-suffix-byte-ranges

Conversation

@Mirochill

Copy link
Copy Markdown

A request such as Range: bytes=-100 for a four-byte representation currently produces a 416 response. RFC 9110 section 14.1.2 specifies that a suffix longer than the selected representation selects the entire representation.

Clamp the resolved suffix start to zero for non-empty representations. Update the existing contradictory unsatisfiable assertion, cover suffix lengths equal to and larger than the representation, and test a complete conditional response including its status, Content-Range, Content-Length and body. Add an unreleased changelog entry.

Specification: https://www.rfc-editor.org/rfc/rfc9110.html#section-14.1.2

Validation:

  • Before the fix: three new regressions fail (two oversized range cases and the 416 response).
  • Python 3.14.8: the complete suite passes, 2,402 passed and one expected failure.
  • Statement coverage is 100% for all 5,123 statements, including the byte-range module.
  • Repository-wide Black (44 files) and isort checks pass, as do check-manifest, source/wheel builds, twine check and the documentation build with warnings treated as errors; git diff --check passes.

AI assistance: this patch and its tests were developed with OpenAI Codex.

Existing behavior for empty representations and zero-length suffixes is outside this fix.

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.

1 participant