func (m retryMiddleware) defaultBackoff(resp *http.Response, backoff time.Duration) (time.Duration, error) {
	if header := resp.Header.Get("Retry-After"); header != "" {
		// Attempt to parse the header from the request.
		//
		// Check for delay in seconds first, before checking for a http-date
		seconds, err := strconv.ParseInt(header, 10, 64)
		if err == nil {
			return m.clampBackoff(time.Second * time.Duration(seconds))
		}
		// Check for http-date.
		date, err := time.Parse(time.RFC1123, header)
		if err == nil {
			return m.clampBackoff(m.clock.Now().Sub(date))
		}
		url := ""
		if resp.Request != nil {
			url = resp.Request.URL.String()
		}
		m.logger.Errorf("unable to parse Retry-After header %s from %s", header, url)
	}

	return m.clampBackoff(backoff)
}
// defaultBackoff attempts to workout a good backoff strategy based on the
// backoff policy or the status code from the response.
//
// RFC7231 states that the retry-after header can look like the following:
//
//  - Retry-After: <http-date>
//  - Retry-After: <delay-seconds>
//
defaultBackoff attempts to workout a good backoff strategy based on the
backoff policy or the status code from the response.

RFC7231 states that the retry-after header can look like the following.

- Retry-After:
- Retry-After: 
// defaultBackoff attempts to workout a good backoff strategy based on the // backoff policy or the status code from the response . // // RFC7231 states that the retry - after header can look like the following : // // - Retry - After : <http - date > // - Retry - After : <delay - seconds > //
func (m retryMiddleware) defaultBackoff(resp *http.Response, backoff time.Duration) (time.Duration, error) {
	if header := resp.Header.Get("Retry-After"); header != "" {
		 Check for delay in seconds first, before checking for a http-date
		seconds, err := strconv.ParseInt(header, 10, 64)
		if err == nil {
			return m.clampBackoff(time.Second * time.Duration(seconds))
		}
		 Check for http-date.
		date, err := time.Parse(time.RFC1123, header)
		if err == nil {
			return m.clampBackoff(m.clock.Now().Sub(date))
		}
		url := ""
		if resp.Request != nil {
			url = resp.Request.URL.String()
		}
		m.logger.Errorf("unable to parse Retry-After header %s from %s", header, url)
	}
	return m.clampBackoff(backoff)
}
func ( m retryMiddleware ) defaultBackoff ( resp * http . Response , backoff time . Duration ) ( time . Duration , error ) { if header := resp . Header . Get ( " " ) ; header != " " { seconds , err := strconv . ParseInt ( header , 10 , 64 ) if err == nil { return m . clampBackoff ( time . Second * time . Duration ( seconds ) ) } date , err := time . Parse ( time . RFC1123 , header ) if err == nil { return m . clampBackoff ( m . clock . Now ( ) . Sub ( date ) ) } url := " " if resp . Request != nil { url = resp . Request . URL . String ( ) } m . logger . Errorf ( " " , header , url ) } return m . clampBackoff ( backoff ) }
defaultBackoff attempts to workout a good backoff strategy based on the
backoff policy or the status code from the response.
defaultBackoff attempts to workout a good backoff strategy based on the backoff policy or the status code from the response .
// Attempt to parse the header from the request. // // Check for delay in seconds first, before checking for a http-date // Check for http-date.