mirror of
https://github.com/octoleo/restic.git
synced 2024-12-25 04:05:58 +00:00
backend: return correct error on upload/request timeout
This commit is contained in:
parent
7642e05eed
commit
61e1f4a916
@ -65,6 +65,9 @@ func (w *watchdogRoundtripper) RoundTrip(req *http.Request) (*http.Response, err
|
|||||||
|
|
||||||
resp, err := w.rt.RoundTrip(req)
|
resp, err := w.rt.RoundTrip(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if isTimeout(err) {
|
||||||
|
err = errRequestTimeout
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ func TestUploadTimeout(t *testing.T) {
|
|||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
|
|
||||||
resp, err := rt.RoundTrip(req)
|
resp, err := rt.RoundTrip(req)
|
||||||
rtest.Equals(t, context.Canceled, err)
|
rtest.Equals(t, errRequestTimeout, err)
|
||||||
// make linter happy
|
// make linter happy
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
rtest.OK(t, resp.Body.Close())
|
rtest.OK(t, resp.Body.Close())
|
||||||
@ -162,7 +162,7 @@ func TestProcessingTimeout(t *testing.T) {
|
|||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
|
|
||||||
resp, err := rt.RoundTrip(req)
|
resp, err := rt.RoundTrip(req)
|
||||||
rtest.Equals(t, context.Canceled, err)
|
rtest.Equals(t, errRequestTimeout, err)
|
||||||
// make linter happy
|
// make linter happy
|
||||||
if resp != nil {
|
if resp != nil {
|
||||||
rtest.OK(t, resp.Body.Close())
|
rtest.OK(t, resp.Body.Close())
|
||||||
|
Loading…
Reference in New Issue
Block a user