diff --git a/shared/packages/worker/src/worker/accessorHandlers/http.ts b/shared/packages/worker/src/worker/accessorHandlers/http.ts index 8bda82a2..bb1b2d12 100644 --- a/shared/packages/worker/src/worker/accessorHandlers/http.ts +++ b/shared/packages/worker/src/worker/accessorHandlers/http.ts @@ -104,7 +104,7 @@ export class HTTPAccessorHandle extends GenericAccessorHandle { const header = await this.fetchHeader() - if (header.status >= 400) { + if (this.isBadHTTPResponseCode(header.status)) { return { success: false, reason: { @@ -149,6 +149,12 @@ export class HTTPAccessorHandle extends GenericAccessorHandle { @@ -400,7 +406,7 @@ export class HTTPAccessorHandle extends GenericAccessorHandle= 400) { + if (this.isBadHTTPResponseCode(result.status)) { const text = await result.text() throw new Error( `deletePackageIfExists: Bad response: [${result.status}]: ${result.statusText}, DELETE ${this.fullUrl}, ${text}` @@ -422,7 +428,7 @@ export class HTTPAccessorHandle extends GenericAccessorHandle { const result = await fetchWithTimeout(url) if (result.status === 404) return undefined - if (result.status >= 400) { + if (this.isBadHTTPResponseCode(result.status)) { const text = await result.text() throw new Error( `getPackagesToRemove: Bad response: [${result.status}]: ${result.statusText}, GET ${url}, ${text}` @@ -437,7 +443,7 @@ export class HTTPAccessorHandle extends GenericAccessorHandle= 400) { + if (this.isBadHTTPResponseCode(result.status)) { const text = await result.text() throw new Error(`storeJSON: Bad response: [${result.status}]: ${result.statusText}, POST ${url}, ${text}`) } @@ -449,6 +455,9 @@ export class HTTPAccessorHandle extends GenericAccessorHandle= 400 + } } interface HTTPHeaders { contentType: string | null diff --git a/shared/packages/worker/src/worker/accessorHandlers/httpProxy.ts b/shared/packages/worker/src/worker/accessorHandlers/httpProxy.ts index 21d5544b..8c2d44e8 100644 --- a/shared/packages/worker/src/worker/accessorHandlers/httpProxy.ts +++ b/shared/packages/worker/src/worker/accessorHandlers/httpProxy.ts @@ -109,7 +109,7 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle { const header = await this.fetchHeader() - if (header.status >= 400) { + if (this.isBadHTTPResponseCode(header.status)) { return { success: false, reason: { @@ -152,6 +152,12 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle { @@ -176,7 +182,7 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle { - if (result.status >= 400) { + if (this.isBadHTTPResponseCode(result.status)) { throw new Error( `Upload file: Bad response: [${result.status}]: ${result.statusText} POST "${this.fullUrl}"` ) @@ -389,7 +395,7 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle= 400) { + if (this.isBadHTTPResponseCode(result.status)) { const text = await result.text() throw new Error( `deletePackageIfExists: Bad response: [${result.status}]: ${result.statusText}, DELETE ${this.fullUrl}, ${text}` @@ -411,7 +417,7 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle { const result = await fetchWithTimeout(url) if (result.status === 404) return undefined - if (result.status >= 400) { + if (this.isBadHTTPResponseCode(result.status)) { const text = await result.text() throw new Error( `getPackagesToRemove: Bad response: [${result.status}]: ${result.statusText}, GET ${url}, ${text}` @@ -426,7 +432,7 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle= 400) { + if (this.isBadHTTPResponseCode(result.status)) { const text = await result.text() throw new Error(`storeJSON: Bad response: [${result.status}]: ${result.statusText}, POST ${url}, ${text}`) } @@ -438,6 +444,9 @@ export class HTTPProxyAccessorHandle extends GenericAccessorHandle= 400 + } } interface HTTPHeaders { contentType: string | null