From 4dcb84a55e79f8c44854f1900aeff0434fa4a418 Mon Sep 17 00:00:00 2001 From: MercornKing Date: Thu, 30 Jul 2026 12:34:09 +0100 Subject: [PATCH] fix: handle HTTP-date format in Retry-After header --- github/client.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 github/client.go diff --git a/github/client.go b/github/client.go new file mode 100644 index 0000000..ae63c4c --- /dev/null +++ b/github/client.go @@ -0,0 +1,21 @@ +package github + +import ( + "net/http" + "strconv" + "time" +) + +func ParseRetryAfter(resp *http.Response) time.Duration { + v := resp.Header.Get("Retry-After") + if v == "" { + return 0 + } + if sec, err := strconv.Atoi(v); err == nil { + return time.Duration(sec) * time.Second + } + if t, err := time.Parse(http.TimeFormat, v); err == nil { + return time.Until(t) + } + return 0 +}