forked from TrueCloudLab/rclone
fs: fix FixRangeOption to make fetch to end Range options absolute
Before this change FixRangeOption was leaving `Range: bytes=21-` alone, thus not fulfilling its contract of making Range requests absolute. As it happens this form isn't supported by Cloudflare R2. After this change the request is normalised to `Range: bytes=21-25`. See: #5642
This commit is contained in:
parent
e5974ac4b0
commit
1e66d052fd
2 changed files with 4 additions and 3 deletions
|
@ -158,7 +158,8 @@ func FixRangeOption(options []OpenOption, size int64) {
|
||||||
x = &RangeOption{Start: size - x.End, End: -1}
|
x = &RangeOption{Start: size - x.End, End: -1}
|
||||||
options[i] = x
|
options[i] = x
|
||||||
}
|
}
|
||||||
if x.End > size {
|
// If end is too big or undefined, fetch to the end
|
||||||
|
if x.End > size || x.End < 0 {
|
||||||
x = &RangeOption{Start: x.Start, End: size - 1}
|
x = &RangeOption{Start: x.Start, End: size - 1}
|
||||||
options[i] = x
|
options[i] = x
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,7 @@ func TestFixRangeOptions(t *testing.T) {
|
||||||
&RangeOption{Start: 1, End: -1},
|
&RangeOption{Start: 1, End: -1},
|
||||||
},
|
},
|
||||||
want: []OpenOption{
|
want: []OpenOption{
|
||||||
&RangeOption{Start: 1, End: -1},
|
&RangeOption{Start: 1, End: 99},
|
||||||
},
|
},
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
|
@ -193,7 +193,7 @@ func TestFixRangeOptions(t *testing.T) {
|
||||||
&RangeOption{Start: -1, End: 10},
|
&RangeOption{Start: -1, End: 10},
|
||||||
},
|
},
|
||||||
want: []OpenOption{
|
want: []OpenOption{
|
||||||
&RangeOption{Start: 90, End: -1},
|
&RangeOption{Start: 90, End: 99},
|
||||||
},
|
},
|
||||||
size: 100,
|
size: 100,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue