Skip to content

Commit 0e4e17c

Browse files
kescherCodemmalerba
authored andcommitted
refactor(http): HttpResponseBase.statusText (angular#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 angular#64176
1 parent 6169fa5 commit 0e4e17c

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

goldens/public-api/common/http/index.api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2987,6 +2987,7 @@ export abstract class HttpResponseBase {
29872987
readonly redirected?: boolean;
29882988
readonly responseType?: ResponseType;
29892989
readonly status: number;
2990+
// @deprecated
29902991
readonly statusText: string;
29912992
readonly type: HttpEventType.Response | HttpEventType.ResponseHeader;
29922993
readonly url: string | null;

packages/common/http/src/response.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ export abstract class HttpResponseBase {
168168
* Textual description of response status code, defaults to OK.
169169
*
170170
* Do not depend on this.
171+
*
172+
* @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.
171173
*/
172174
readonly statusText: string;
173175

@@ -405,6 +407,7 @@ export class HttpErrorResponse extends HttpResponseBase implements Error {
405407
if (this.status >= 200 && this.status < 300) {
406408
this.message = `Http failure during parsing for ${init.url || '(unknown url)'}`;
407409
} else {
410+
// TODO: Cleanup G3 to update the tests that rely on having the status text in the Error message.
408411
this.message = `Http failure response for ${init.url || '(unknown url)'}: ${init.status} ${
409412
init.statusText
410413
}`;

0 commit comments

Comments
 (0)