Repository navigation
fix(engine): probe range support with the first byte - #8
Conversation
troke12
left a comment
There was a problem hiding this comment.
Makes the code match its own comment, but on its own it regresses a case that works today: a server that answers 206 to bytes=0-0 but 200 to a range covering the whole file. The probe now sets RangeOK=true; with a single chunk (Connections=1, or any file < 128 KiB because the small tail folds into the previous chunk) the worker asks for bytes=0-(N-1), gets 200, and fails with "server ignored Range" after 8 retries. On main that file downloads fine on one stream.
#10 handles exactly this ("a 200 for a range covering the whole file is written from byte 0"), so this should land after #10 (or carry that handling). Please add a Connections=1 / small-file test.
Heads-up: the test fixtures in #7, #10 and #11 detect the probe by its open-ended range; 0-0 breaks that (and makes #11's refused-response test pass vacuously).
Note for the whole set (#1–#11): thanks a lot for these! They are all branched from 5350f79 independently, so every pair conflicts on CHANGELOG.md and most on download.go. main has also moved (e830f5d adds a stream downloader that touches download.go). Could you rebase onto current main and stack them in this order: #1 → #2 → #10 → #8 → #5/#6/#7/#11? #2, #3 and #10 each add their own pass loop / transferCancel in Start; one shared design would be much easier to merge.
The size probe asks for bytes 0-0. A server that answers 200 for a range covering the whole file still shows range support when that one-byte request returns 206.
Review changes on top of the previous commit: - TestProbeFirstByteSingleChunk covers the regression the review found: a server answering 206 to bytes=0-0 but 200 to a range over the whole file, with one connection or a file too small to split. With troke12#10 on main the whole-file 200 is kept, so it completes in one request. - Test servers no longer tell the probe by its open-ended range, which bytes=0-0 broke (troke12#1, troke12#7 and troke12#10 fixtures): isProbe and probeRange in engine_test.go, and testRange reports the probe as not explicit. - The PR's test helper is renamed testWholeSpan (wholeFileRange is now a production function) and the test moves to probe_byte_test.go, as probe_test.go exists on main. ✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)
5093e62 to
4405d07
Compare
|
Rebased onto current |
Summary
The size probe asks for the first byte (
Range: bytes=0-0) instead ofbytes=0-. Some servers answer a range that covers the whole file with200, which hid that they support ranges, so ODM downloaded such files on one stream. With a one-byte probe they answer206and the download is segmented.The regression from the review, now covered
A server that answers
206tobytes=0-0but200to a range covering the whole file: with a single chunk (one connection, or a file under 128 KiB) the transfer asks for exactly that range and used to fail with "server ignored Range". With #10 onmain, a whole-file200(same validator, or none) is kept, so the file completes in one request.TestProbeFirstByteSingleChunkcovers both cases.Commits
80d0305(Ryan Bagas): the original change, rebased onto currentmain. Its test moves toprobe_byte_test.go(probe_test.goexists on main) and the helper is renamedtestWholeSpan. Several existing fixtures fail at this commit until the next one.4405d07: review changes. The single-chunk test, plus test servers that recognise the probe bybytes=0-0(isProbe/probeRange) instead of its open-ended range.Test plan
go test ./...andgo test -race ./internal/engineTestProbeFirstByteStillSegments: segmented with the one-byte probe. Fails with the oldbytes=0-probe.TestProbeFirstByteSingleChunk(one connection / small file): completes with exactly one whole-file 200. Fails if that 200 is not kept.✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)