diff --git a/modules/angular2/src/http/backends/xhr_backend.ts b/modules/angular2/src/http/backends/xhr_backend.ts index e70e2ff51725e..817e3290f3ad9 100644 --- a/modules/angular2/src/http/backends/xhr_backend.ts +++ b/modules/angular2/src/http/backends/xhr_backend.ts @@ -43,6 +43,8 @@ export class XHRConnection implements Connection { } ObservableWrapper.callNext(this.response, new Response(responseOptions)); + // TODO(gdi2290): defer complete if array buffer until done + ObservableWrapper.callReturn(this.response); }); // TODO(jeffbcross): make this more dynamic based on body type diff --git a/modules/angular2/test/http/backends/xhr_backend_spec.ts b/modules/angular2/test/http/backends/xhr_backend_spec.ts index 0a109dae2f76c..88b90d2d24cfa 100644 --- a/modules/angular2/test/http/backends/xhr_backend_spec.ts +++ b/modules/angular2/test/http/backends/xhr_backend_spec.ts @@ -95,6 +95,16 @@ export function main() { existingXHRs[0].dispatchEvent('load'); })); + it('should complete a request', inject([AsyncTestCompleter], async => { + var connection = new XHRConnection(sampleRequest, new MockBrowserXHR(), + new ResponseOptions({type: ResponseTypes.Error})); + ObservableWrapper.subscribe(connection.response, res => { + expect(res.type).toBe(ResponseTypes.Error); + }, null, () => { async.done(); }); + + existingXHRs[0].dispatchEvent('load'); + })); + it('should call abort when disposed', () => { var connection = new XHRConnection(sampleRequest, new MockBrowserXHR()); connection.dispose();