Skip to content

fix(engine): probe range support with the first byte - #8

Merged
troke12 merged 2 commits into
troke12:mainfrom
rigaz29:engine-probe-byte
Oct 19, 2026
Merged

troke12 merged 2 commits into
troke12:mainfrom
rigaz29:engine-probe-byte

Conversation

@rigaz29

@rigaz29 rigaz29 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The size probe asks for the first byte (Range: bytes=0-0) instead of bytes=0-. Some servers answer a range that covers the whole file with 200, which hid that they support ranges, so ODM downloaded such files on one stream. With a one-byte probe they answer 206 and the download is segmented.

The regression from the review, now covered

A server that answers 206 to bytes=0-0 but 200 to 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 on main, a whole-file 200 (same validator, or none) is kept, so the file completes in one request. TestProbeFirstByteSingleChunk covers both cases.

Commits

  • 80d0305 (Ryan Bagas): the original change, rebased onto current main. Its test moves to probe_byte_test.go (probe_test.go exists on main) and the helper is renamed testWholeSpan. 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 by bytes=0-0 (isProbe/probeRange) instead of its open-ended range.

Test plan

✨ Generated with Claude Code (claude.ai/claude-code) 2.1.303 (claude-opus-5-5)

@troke12 troke12 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

rigaz29 and others added 2 commits October 19, 2026 10:19
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)
@troke12

troke12 commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Rebased onto current main (with #10 merged, which handles the whole-file 200 the review pointed out) and added the requested Connections=1 / small-file test. Test servers now recognise the probe by bytes=0-0 instead of its open-ended range, as flagged in the review. Your commit is kept with you as author; the review changes are a separate commit on top. Thanks!

@troke12
troke12 merged commit 956df7b into troke12:main Oct 19, 2026
5 checks passed
@rigaz29
rigaz29 deleted the engine-probe-byte branch October 19, 2026 05:01
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.

2 participants