Minor corrections to error handling logic in httpu.
This commit is contained in:
parent
5cd41e8371
commit
9c7a5054da
@ -91,13 +91,17 @@ func (httpu *HTTPUClient) Do(req *http.Request, timeout time.Duration, numSends
|
|||||||
// 2048 bytes should be sufficient for most networks.
|
// 2048 bytes should be sufficient for most networks.
|
||||||
n, _, err := httpu.conn.ReadFrom(responseBytes)
|
n, _, err := httpu.conn.ReadFrom(responseBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err, ok := err.(net.Error); ok && err.Timeout() {
|
if err, ok := err.(net.Error); ok {
|
||||||
break
|
if err.Timeout() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if err.Temporary() {
|
||||||
|
// Sleep in case this is a persistent error to avoid pegging CPU until deadline.
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
log.Print("httpu: error while receiving response: %v", err)
|
return nil, err
|
||||||
// Sleep in case this is a persistent error to avoid pegging CPU until deadline.
|
|
||||||
time.Sleep(10 * time.Millisecond)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse response.
|
// Parse response.
|
||||||
|
Loading…
Reference in New Issue
Block a user