fix(http): avoid abort a request when fetch operation is completed (#37367)
`abort` method is calling, even if fetch operation is completed Fixes https://github.com/angular/angular/issues/36537 PR Close #37367
This commit is contained in:
parent
ef1fb6dee4
commit
8a74508130
|
@ -339,7 +339,9 @@ export class HttpXhrBackend implements HttpBackend {
|
|||
}
|
||||
|
||||
// Finally, abort the in-flight request.
|
||||
xhr.abort();
|
||||
if (xhr.readyState !== xhr.DONE) {
|
||||
xhr.abort();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -147,6 +147,17 @@ const XSSI_PREFIX = ')]}\'\n';
|
|||
});
|
||||
factory.mock.mockErrorEvent(new Error('blah'));
|
||||
});
|
||||
it('avoids abort a request when fetch operation is completed', done => {
|
||||
const abort = jasmine.createSpy('abort');
|
||||
|
||||
backend.handle(TEST_POST).toPromise().then(() => {
|
||||
expect(abort).not.toHaveBeenCalled();
|
||||
done();
|
||||
});
|
||||
|
||||
factory.mock.abort = abort;
|
||||
factory.mock.mockFlush(200, 'OK', 'Done');
|
||||
});
|
||||
describe('progress events', () => {
|
||||
it('are emitted for download progress', done => {
|
||||
backend.handle(TEST_POST.clone({reportProgress: true}))
|
||||
|
|
Loading…
Reference in New Issue