MCPcopy Index your code
hub / github.com/docker/docker-agent / parseRetryAfterHeader

Function parseRetryAfterHeader

pkg/modelerrors/modelerrors.go:549–565  ·  view source on GitHub ↗

parseRetryAfterHeader parses a Retry-After header value. Supports both seconds (integer) and HTTP-date formats per RFC 7231 §7.1.3. Returns 0 if the value is empty, invalid, or results in a non-positive duration.

(value string)

Source from the content-addressed store, hash-verified

547// Supports both seconds (integer) and HTTP-date formats per RFC 7231 §7.1.3.
548// Returns 0 if the value is empty, invalid, or results in a non-positive duration.
549func parseRetryAfterHeader(value string) time.Duration {
550 if value == "" {
551 return 0
552 }
553 // Try integer seconds first (most common for rate limits)
554 if seconds, err := strconv.Atoi(value); err == nil && seconds > 0 {
555 return time.Duration(seconds) * time.Second
556 }
557 // Try HTTP-date format
558 if t, err := http.ParseTime(value); err == nil {
559 d := time.Until(t)
560 if d > 0 {
561 return d
562 }
563 }
564 return 0
565}
566
567// ClassifyModelError classifies an error for the retry/fallback decision.
568//

Callers 2

WrapHTTPErrorFunction · 0.85

Calls 1

DurationMethod · 0.80

Tested by 1