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
This commit is contained in:
Jeremy Kescher 2024-10-04 15:15:12 +02:00 committed by Miles Malerba
parent 6169fa5888
commit 0e4e17cd97
2 changed files with 4 additions and 0 deletions

View file

@ -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;

View file

@ -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
}`;