Repository navigation
lib/http: return 416 for ranges --rc-serve and serve restic can't satisfy - #10141
Merged
Merged
Conversation
…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.
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.
What does this change do?
lib/http/serve.Object(used by--rc-serveandserve restic) answered a Range it couldn't satisfy with a206and a malformedContent-Range, e.g.bytes 10-9/10forbytes=10-on a 10 byte file. That is the requestcurl -C -andwget -csend to resume a complete download, and they expect a416.Ranges starting at or after the end of the object, or ending before they start, now get
416withContent-Range: bytes */size. A Range on an empty object is ignored. Both matchhttp.ServeContent, whichserve httpalready uses. Ranges that run past the end are still clamped as before.Tests: the new
TestObjectRangeNotSatisfiableandTestObjectRangeEmptyObjectfail on master (206 instead of 416, andbytes=20-panics the test object).TestObjectRangeEndPastObjectpins the existing clamping. Checked end to end withcurl -C -againstrclone rcd --rc-serve: master returns206/bytes 10-9/10, this branch416/bytes */10, the same asserve http. All packages importinglib/http/servepass exceptcmd/gitannex(needs git-annex) andTestS3Minio(needs MinIO), which fail the same way on master. golangci-lint is clean.Linked issue
Fixes #10140
Checklist
test_allpasses for this backend and if submitting a new backend can provide a test account for the integration tester - see CONTRIBUTING.md.