diff --git a/lib/util/http/__snapshots__/index.spec.ts.snap b/lib/util/http/__snapshots__/index.spec.ts.snap index 2d399e98b959442230ccdab214ba35db91cd0b41..13e7e4858f20ebd52b11db09d11b30e97353f72d 100644 --- a/lib/util/http/__snapshots__/index.spec.ts.snap +++ b/lib/util/http/__snapshots__/index.spec.ts.snap @@ -2,6 +2,7 @@ exports[`util/http/index deleteJson 1`] = ` Object { + "authorization": false, "body": Object {}, "headers": Object { "content-type": "application/json", @@ -12,6 +13,7 @@ Object { exports[`util/http/index get 1`] = ` Object { + "authorization": false, "body": "", "headers": Object {}, "statusCode": 200, @@ -20,6 +22,7 @@ Object { exports[`util/http/index getJson 1`] = ` Object { + "authorization": false, "body": Object { "test": true, }, @@ -30,6 +33,7 @@ Object { exports[`util/http/index headJson 1`] = ` Object { + "authorization": false, "body": Object {}, "headers": Object { "content-type": "application/json", @@ -40,6 +44,7 @@ Object { exports[`util/http/index patchJson 1`] = ` Object { + "authorization": false, "body": Object {}, "headers": Object { "content-type": "application/json", @@ -50,6 +55,7 @@ Object { exports[`util/http/index postJson 1`] = ` Object { + "authorization": false, "body": Object {}, "headers": Object { "content-type": "application/json", @@ -60,6 +66,7 @@ Object { exports[`util/http/index putJson 1`] = ` Object { + "authorization": false, "body": Object {}, "headers": Object { "content-type": "application/json", @@ -70,6 +77,7 @@ Object { exports[`util/http/index retries 1`] = ` Object { + "authorization": false, "body": "", "headers": Object { "x-some-header": "abc", diff --git a/lib/util/http/index.ts b/lib/util/http/index.ts index d735e5a620cc4fe99d5729c1f7efe2b8bdb6fe47..45b886d8b76cf0001f048b7354190a4a92ead37b 100644 --- a/lib/util/http/index.ts +++ b/lib/util/http/index.ts @@ -44,6 +44,7 @@ export interface HttpResponse<T = string> { statusCode: number; body: T; headers: any; + authorization?: boolean; } function cloneResponse<T>(response: any): HttpResponse<T> { @@ -52,6 +53,7 @@ function cloneResponse<T>(response: any): HttpResponse<T> { statusCode: response.statusCode, body: clone<T>(response.body), headers: clone(response.headers), + authorization: !!response.authorization, }; } @@ -148,6 +150,7 @@ export class Http<GetOptions = HttpOptions, PostOptions = HttpPostOptions> { try { const res = await resPromise; + res.authorization = !!options?.headers?.authorization; return cloneResponse(res); } catch (err) { const { abortOnError, abortIgnoreStatusCodes } = options;