Skip to content
This repository was archived by the owner on Mar 28, 2019. It is now read-only.

Commit 9013ce9

Browse files
author
Kit Cambridge
committed
Unwrap temporary HTTP client errors.
See golang/go#9405.
1 parent dc79f59 commit 9013ce9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/github.com/mozilla-services/pushgo/client/test_client.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,26 @@ func PushThrough(conn *Conn, channels, updates int) error {
7777
return t.Do()
7878
}
7979

80+
func isTemporaryNetErr(err error) bool {
81+
netErr, ok := err.(net.Error)
82+
return ok && netErr.Temporary()
83+
}
84+
8085
func IsTemporaryErr(err error) bool {
86+
if isTemporaryNetErr(err) {
87+
return true
88+
}
8189
urlErr, ok := err.(*url.Error)
8290
if !ok {
8391
return false
8492
}
93+
if isTemporaryNetErr(urlErr.Err) {
94+
return true
95+
}
8596
opErr, ok := urlErr.Err.(*net.OpError)
97+
if isTemporaryNetErr(opErr.Err) {
98+
return true
99+
}
86100
return ok && (opErr.Err == syscall.EPIPE || opErr.Err == syscall.ECONNRESET)
87101
}
88102

0 commit comments

Comments
 (0)