You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
http2: retry requests after receiving REFUSED STREAM
RoundTrip will retry a request if it receives REFUSED_STREAM. To guard
against servers that use REFUSED_STREAM to encourage rate limiting, or
servers that return REFUSED_STREAM deterministically for some requests,
we retry after an exponential backoff and we cap the number of retries.
The exponential backoff starts on the second retry, with a backoff
sequence of 1s, 2s, 4s, etc, with 10% random jitter.
The retry cap was set to 6, somewhat arbitrarily. Rationale: this is
what Firefox does.
Updates golang/go#20985
Change-Id: I4dcac4392ac4a3220d6d839f28bf943fe6b3fea7
Reviewed-on: https://go-review.googlesource.com/50471
Run-TryBot: Tom Bergan <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Brad Fitzpatrick <[email protected]>
// If the Body is nil (or http.NoBody), it's safe to reuse
382
-
// this request and its Body.
383
-
ifreq.Body==nil||reqBodyIsNoBody(req.Body) {
384
-
returnreq, nil
385
-
}
386
-
// Otherwise we depend on the Request having its GetBody
387
-
// func defined.
388
-
getBody:=reqGetBody(req) // Go 1.8: getBody = req.GetBody
389
-
ifgetBody==nil {
390
-
returnnil, errors.New("http2: Transport: peer server initiated graceful shutdown after some of Request.Body was written; define Request.GetBody to avoid this error")
391
-
}
392
-
body, err:=getBody()
393
-
iferr!=nil {
394
-
returnnil, err
395
-
}
396
-
newReq:=*req
397
-
newReq.Body=body
398
-
return&newReq, nil
399
405
}
406
+
// If the Body is nil (or http.NoBody), it's safe to reuse
407
+
// this request and its Body.
408
+
ifreq.Body==nil||reqBodyIsNoBody(req.Body) {
409
+
returnreq, nil
410
+
}
411
+
// Otherwise we depend on the Request having its GetBody
412
+
// func defined.
413
+
getBody:=reqGetBody(req) // Go 1.8: getBody = req.GetBody
414
+
ifgetBody==nil {
415
+
returnnil, fmt.Errorf("http2: Transport: cannot retry err [%v] after Request.Body was written; define Request.GetBody to avoid this error", err)
0 commit comments