Skip to content

lib/http: return 416 for ranges --rc-serve and serve restic can't satisfy - #10141

Merged
ncw merged 1 commit into
rclone:masterfrom
r0h1tb:fix/serve-range-not-satisfiable
Oct 29, 2026
Merged

ncw merged 1 commit into
rclone:masterfrom
r0h1tb:fix/serve-range-not-satisfiable

Conversation

@r0h1tb

@r0h1tb r0h1tb commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

What does this change do?

lib/http/serve.Object (used by --rc-serve and serve restic) answered a Range it couldn't satisfy with a 206 and a malformed Content-Range, e.g. bytes 10-9/10 for bytes=10- on a 10 byte file. That is the request curl -C - and wget -c send to resume a complete download, and they expect a 416.

Ranges starting at or after the end of the object, or ending before they start, now get 416 with Content-Range: bytes */size. A Range on an empty object is ignored. Both match http.ServeContent, which serve http already uses. Ranges that run past the end are still clamped as before.

Tests: the new TestObjectRangeNotSatisfiable and TestObjectRangeEmptyObject fail on master (206 instead of 416, and bytes=20- panics the test object). TestObjectRangeEndPastObject pins the existing clamping. Checked end to end with curl -C - against rclone rcd --rc-serve: master returns 206 / bytes 10-9/10, this branch 416 / bytes */10, the same as serve http. All packages importing lib/http/serve pass except cmd/gitannex (needs git-annex) and TestS3Minio (needs MinIO), which fail the same way on master. golangci-lint is clean.

Linked issue

Fixes #10140

Checklist

  • This change is trivial OR it has been discussed and agreed in the linked issue.
  • I have read the contribution guidelines.
  • (If I used AI tools to help write this code) I have read and understood the AI-assisted contributions guidance, and I have tested and take ownership of this change myself.
  • I have added tests for all changes in this PR if appropriate.
  • I have added documentation for the changes if appropriate.
  • All commit messages are in house style.
  • (Backend changes only) test_all passes for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.
  • This Pull Request is ready for review.

…isfy - fixes rclone#10140

Before this change, a Range request starting at or after the end of the
object, or ending before it started, was answered with a 206 and a
malformed Content-Range such as "bytes 10-9/10". Resuming a complete
download with curl -C - or wget -c, which send such a range and expect a
416, saw a broken partial response instead.

After this change these requests get a 416 with "Content-Range: bytes */size",
and a Range on an empty object is ignored, the same as http.ServeContent
does for rclone serve http.
@r0h1tb
r0h1tb requested a review from ncw as a code owner October 19, 2026 11:50

@ncw ncw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you :-)

@ncw
ncw merged commit f17b89b into rclone:master Oct 29, 2026
9 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.

rc-serve and serve restic answer unsatisfiable Range requests with a malformed 206

2 participants