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.timeout = request.timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
xhr.onreadystatechange = () => {
|
xhr.onload = () => {
|
||||||
if (xhr.readyState === 4) {
|
if (request.abortSignal) {
|
||||||
if (request.abortSignal) {
|
request.abortSignal.onabort = null;
|
||||||
request.abortSignal.onabort = null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Some browsers report xhr.status == 0 when the
|
if (xhr.status >= 200 && xhr.status < 300) {
|
||||||
// response has been cut off or there's been a TCP FIN.
|
resolve(new HttpResponse(xhr.status, xhr.statusText, xhr.response || xhr.responseText));
|
||||||
// Treat it like a 200 with no response.
|
} else {
|
||||||
if (xhr.status === 0) {
|
reject(new HttpError(xhr.statusText, xhr.status));
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue