mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
committed by
Miles Malerba
parent
6169fa5888
commit
0e4e17cd97
@@ -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;
|
||||
|
||||
@@ -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
|
||||
}`;
|
||||
|
||||
Reference in New Issue
Block a user