mirror of
https://github.com/rclone/rclone.git
synced 2024-12-23 07:29:35 +01:00
putio: fix multithread download and other ranged requests
Before this change the 206 responses from putio Range requests were being returned as errors. This change checks for 200 and 206 in the GET response now.
This commit is contained in:
parent
9e9ead2ac4
commit
be9ee1d138
@ -12,11 +12,13 @@ import (
|
|||||||
"github.com/rclone/rclone/lib/pacer"
|
"github.com/rclone/rclone/lib/pacer"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkStatusCode(resp *http.Response, expected int) error {
|
func checkStatusCode(resp *http.Response, expected ...int) error {
|
||||||
if resp.StatusCode != expected {
|
for _, code := range expected {
|
||||||
return &statusCodeError{response: resp}
|
if resp.StatusCode == code {
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &statusCodeError{response: resp}
|
||||||
}
|
}
|
||||||
|
|
||||||
type statusCodeError struct {
|
type statusCodeError struct {
|
||||||
|
@ -244,7 +244,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return shouldRetry(ctx, err)
|
return shouldRetry(ctx, err)
|
||||||
}
|
}
|
||||||
if err := checkStatusCode(resp, 200); err != nil {
|
if err := checkStatusCode(resp, 200, 206); err != nil {
|
||||||
return shouldRetry(ctx, err)
|
return shouldRetry(ctx, err)
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user