From 0e4e17cd97d7a5f7ccc40405ba2103a78e1e1298 Mon Sep 17 00:00:00 2001 From: Jeremy Kescher Date: Fri, 4 Oct 2024 15:15:12 +0200 Subject: [PATCH] refactor(http): `HttpResponseBase.statusText` (#64176) Since HTTP/2, responses no longer contain a status text besides the status code, which caused our default value of 'OK' to be used in HttpErrorResponse.message. DEPRECATED: `HttpResponseBase.statusText` is deprecated PR Close #64176 --- goldens/public-api/common/http/index.api.md | 1 + packages/common/http/src/response.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/goldens/public-api/common/http/index.api.md b/goldens/public-api/common/http/index.api.md index 51b5ea158aa..5349756c46b 100644 --- a/goldens/public-api/common/http/index.api.md +++ b/goldens/public-api/common/http/index.api.md @@ -2987,6 +2987,7 @@ export abstract class HttpResponseBase { readonly redirected?: boolean; readonly responseType?: ResponseType; readonly status: number; + // @deprecated readonly statusText: string; readonly type: HttpEventType.Response | HttpEventType.ResponseHeader; readonly url: string | null; diff --git a/packages/common/http/src/response.ts b/packages/common/http/src/response.ts index eec106397c0..d3b8056357a 100644 --- a/packages/common/http/src/response.ts +++ b/packages/common/http/src/response.ts @@ -168,6 +168,8 @@ export abstract class HttpResponseBase { * Textual description of response status code, defaults to OK. * * Do not depend on this. + * + * @deprecated With HTTP/2 and later versions, this will incorrectly remain set to 'OK' even when the status code of a response is not 200. */ readonly statusText: string; @@ -405,6 +407,7 @@ export class HttpErrorResponse extends HttpResponseBase implements Error { if (this.status >= 200 && this.status < 300) { this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`; } else { + // TODO: Cleanup G3 to update the tests that rely on having the status text in the Error message. this.message = `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${ init.statusText }`;