Fix rate limit checking in GhApiClient (#1725)

* Fix rate limit checking in `GhApiClient`

 - Mv logic into `binstalk_downloader`
 - Check for `RETRY_AFTER` and `x-ratelimit-remaining` on any status code

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

* Fix clippy lint

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>

---------

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-06-11 22:37:48 +10:00 committed by GitHub
parent 3aae883467
commit 238e0f6318
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 43 deletions

View file

@ -299,14 +299,13 @@ impl GhApiClient {
.send(false)
.await?;
match check_http_status_and_header(&response) {
match check_http_status_and_header(response) {
Err(GhApiError::Unauthorized) => {
self.0.is_auth_token_valid.store(false, Relaxed);
Err(GhApiError::Unauthorized)
}
res => res?,
res => res.map(Download::from_response),
}
Ok(Download::from_response(response))
}
}