adds logging during failure condition for low-level-retry

This commit is contained in:
zackees 2025-02-13 13:37:50 -08:00
parent b5e72e2fc3
commit 79d82fc841

View File

@ -400,7 +400,18 @@ func (f *Fs) shouldRetry(ctx context.Context, resp *http.Response, err error) (b
}
return true, err
}
return f.shouldRetryNoReauth(ctx, resp, err)
shouldRetry, err := f.shouldRetryNoReauth(ctx, resp, err)
if !shouldRetry && resp != nil {
// Log details when not retrying to help with debugging
var peek []byte
if resp.Body != nil {
peek, _ = io.ReadAll(io.LimitReader(resp.Body, 50))
_ = resp.Body.Close()
}
fs.Debugf(f, "Not retrying HTTP response: status=%d headers=%v body=%q",
resp.StatusCode, resp.Header, string(peek))
}
return shouldRetry, err
}
// errorHandler parses a non 2xx error response into an error