Fix roundtripper doesn't increase request timeout setting after each retry (#1216)

This commit is contained in:
Ta-Ching Chen
2019-07-19 00:46:57 +08:00
committed by GitHub
parent 3bffd27c74
commit 6e00733f68
6 changed files with 147 additions and 122 deletions
+23 -1
View File
@@ -26,7 +26,7 @@ import (
type (
Error struct {
err error
err net.Error
}
)
@@ -92,6 +92,28 @@ func (e Error) IsConnRefusedError() bool {
return false
}
// IsTimeoutError returns true if its a network timeout error
func (e Error) IsTimeoutError() bool {
if e.err.Timeout() {
return true
}
opErr, ok := e.err.(*net.OpError)
if ok {
switch t := opErr.Err.(type) {
case *os.SyscallError:
if errno, ok := t.Err.(syscall.Errno); ok {
switch errno {
case syscall.ETIMEDOUT:
return true
}
}
}
}
return false
}
// IsUnsupportedProtoScheme returns true if an error is a "unsupported protocol scheme" error
func (e Error) IsUnsupportedProtoScheme() bool {
urlErr, ok := e.err.(*url.Error)