webdav: fix Open Range requests to fix 4shared mount

Before this change the webdav backend didn't truncate Range requests
to the size of the object. Most webdav providers are OK with this (it
is RFC compliant), but it causes 4shared to return 500 internal error.

Because Range requests are used in mounting, this meant that mounting
didn't work for 4shared.

This change truncates the Range request to the size of the object.

See: https://forum.rclone.org/t/cant-copy-use-files-on-webdav-mount-4shared-that-have-foreign-characters/21334/
This commit is contained in:
Nick Craig-Wood 2020-12-28 11:31:19 +00:00
parent 72eb74e94a
commit 65eee674b9

View File

@ -1128,6 +1128,7 @@ func (o *Object) Storable() bool {
// Open an object for read // Open an object for read
func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error) { func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.ReadCloser, err error) {
var resp *http.Response var resp *http.Response
fs.FixRangeOption(options, o.size)
opts := rest.Opts{ opts := rest.Opts{
Method: "GET", Method: "GET",
Path: o.filePath(), Path: o.filePath(),