feat: add retry logic to the http client (#2692)

* refactor: extract http client

* feat: add retry logic to http client
This commit is contained in:
Dag 2022-05-08 03:58:57 +02:00 committed by GitHub
parent 0c7a7f320f
commit 5d77d14f9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 139 additions and 317 deletions

View file

@ -610,8 +610,8 @@ EOD;
try {
$result = getContents($uri, $this->authHeaders, array(), true);
} catch (UnexpectedResponseException $e) {
switch ($e->getResponseCode()) {
} catch (HttpException $e) {
switch ($e->getCode()) {
case 401:
case 403:
if ($retries) {
@ -621,8 +621,8 @@ EOD;
continue 2;
}
default:
$code = $e->getResponseCode();
$data = $e->getResponseBody();
$code = $e->getCode();
$data = $e->getMessage();
returnServerError(<<<EOD
Failed to make api call: $api
HTTP Status: $code