Repository navigation
fix(http): download from servers that ignore ranges or fail HEAD - #613
Merged
Merged
Conversation
A server that advertises Accept-Ranges but answers ranged GETs with the whole file (200) failed the download with "Server returned a different range". The engine now reports that case as a RangeIgnoredException, and HttpDownloadSource restarts the run over one connection from byte zero. A HEAD answered with 500 while GET works (handlers that fail on HEAD) now falls back to the ranged GET probe, as 400/403/404/405/501 already did.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Contributor
Test Results 2 193 files ±0 2 221 suites ±0 57m 22s ⏱️ +41s Results for commit d8f2f8a. ± Comparison against base commit 94bd6b5. This pull request removes 1 and adds 5 tests. Note that renamed tests count towards both. |
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.
Found while running real downloads with the CLI against a local server that misbehaves the way some file servers and caches do.
What changes
HEADsaysAccept-Ranges: bytesbut answers rangedGETs with200and the whole file failed the download withNot supported: Server returned a different range.KtorHttpEnginenow reports that case with aKetchError.Unsupportedcaused by the newRangeIgnoredException, andHttpDownloadSourcerestarts the run over one connection from byte zero. A206with a differentContent-Rangestill fails, as before.HEADfailing with 500. AHEADanswered with 500 whileGETworks (handlers that fail onHEAD) failed after three retries without trying the rangedGETprobe. 500 now joins 400/403/404/405/501 inRangeSupportDetector.HEAD_REFUSED. If the server is really down, the probe fails with the same 5xx and the usual retries apply.Verification
ketchbuilt from this branch, against a local server:/fake-ranges/(Accept-Ranges, 200 to ranges): completes, SHA-256 matches. Before: failed./head/500/(HEAD 500, GET fine): completes, SHA-256 matches. Before: failed after 3 HEAD retries./wrong-range/(206 with another range): still fails withServer returned a different range../gradlew :library:core:jvmTest --tests '*HttpDownloadSourceTest*' --tests '*RangeSupportDetectorTest*' --tests '*FailureLoggingTest*' :library:ktor:jvmTestpasses. The newdownload_serverIgnoringAdvertisedRanges_restartsOverOneConnectioncovers the fallback.download_ignoredRange_failsInsteadOfCorruptingFileis nowdownload_ignoredRange_restartsOverOneConnection: it checks the file is complete and correct, and that the last request asks for the whole file.