This reverts commit 5e38303377.
This commit is contained in:
parent
5c9b64244a
commit
d9272032d0
|
|
@ -94,22 +94,15 @@ export class DefaultHttpClient extends HttpClient {
|
|||
xhr.timeout = request.timeout;
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === 4) {
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = null;
|
||||
}
|
||||
xhr.onload = () => {
|
||||
if (request.abortSignal) {
|
||||
request.abortSignal.onabort = null;
|
||||
}
|
||||
|
||||
// Some browsers report xhr.status == 0 when the
|
||||
// response has been cut off or there's been a TCP FIN.
|
||||
// Treat it like a 200 with no response.
|
||||
if (xhr.status === 0) {
|
||||
resolve(new HttpResponse(200, null, null));
|
||||
} else if (xhr.status >= 200 && xhr.status < 300) {
|
||||
resolve(new HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
|
||||
} else {
|
||||
reject(new HttpError(xhr.statusText, xhr.status));
|
||||
}
|
||||
if (xhr.status >= 200 && xhr.status < 300) {
|
||||
resolve(new HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
|
||||
} else {
|
||||
reject(new HttpError(xhr.statusText, xhr.status));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue