Skip to content

Treat 416 like 501 for unsupported suffix ranges - #10

Merged
thatch merged 3 commits into
mainfrom
thatch/also-code-416
Aug 21, 2026
Merged

thatch merged 3 commits into
mainfrom
thatch/also-code-416

Conversation

@thatch

@thatch thatch commented Aug 21, 2026

Copy link
Copy Markdown
Owner

Live tests were failing because the server we hit most (fastly, in front of files.pythonhosted.org) can return 416 (Range Not Satisfiable) instead of 501 (Not Implemented) for an unsupported open-ended range request.

SeekableHttpFile.__init__ now falls back to a HEAD request on either status code, with mocked tests covering both the urllib and requests backends.

thatch and others added 3 commits August 21, 2026 13:36
Some servers (e.g. fastly, in front of files.pythonhosted.org) reject
an unsupported open-ended range request with 416 (Range Not
Satisfiable) instead of 501 (Not Implemented), breaking the live
tests. Fall back to a HEAD request on either status, and cover both
urllib and requests backends with mocks.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The CDN in front of files.pythonhosted.org now honors the initial
suffix-range request directly instead of rejecting it, so the
optimistic-then-HEAD fallback no longer triggers and one fewer
request is made.
mypy 1.8.0's bundled requests stub types HTTPError.response as
Optional, so --strict flagged e.response.status_code as unsafe. An
HTTPError with no response can't be classified as a range-support
failure anyway, so re-raise it.
@thatch
thatch merged commit af0b78c into main Aug 21, 2026
21 checks passed
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