mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 13:06:30 +02:00
github: Handle empty x-ratelimit-remaining header
Signed-off-by: unilock <unilock@fennet.rentals>
This commit is contained in:
parent
3859b37267
commit
72afdee4d8
@ -37,10 +37,16 @@ func (c *ghApiClient) makeGet(url string) (*http.Response, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ratelimit, err := strconv.Atoi(resp.Header.Get("x-ratelimit-remaining"))
|
// TODO: there is likely a better way to do this
|
||||||
|
ratelimit := 999
|
||||||
|
|
||||||
|
ratelimit_header := resp.Header.Get("x-ratelimit-remaining")
|
||||||
|
if ratelimit_header != "" {
|
||||||
|
ratelimit, err = strconv.Atoi(ratelimit_header)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if resp.StatusCode == 403 && ratelimit == 0 {
|
if resp.StatusCode == 403 && ratelimit == 0 {
|
||||||
return nil, fmt.Errorf("GitHub API ratelimit exceeded; time of reset: %v", resp.Header.Get("x-ratelimit-reset"))
|
return nil, fmt.Errorf("GitHub API ratelimit exceeded; time of reset: %v", resp.Header.Get("x-ratelimit-reset"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user