diff --git a/modules/angular2/src/http/backends/xhr_backend.ts b/modules/angular2/src/http/backends/xhr_backend.ts index f5db5e79f93c6..00ccc53874937 100644 --- a/modules/angular2/src/http/backends/xhr_backend.ts +++ b/modules/angular2/src/http/backends/xhr_backend.ts @@ -64,7 +64,7 @@ export class XHRConnection implements Connection { }; if (isPresent(req.headers)) { - req.headers.forEach((value, name) => { _xhr.setRequestHeader(name, value); }); + req.headers.forEach((values, name) => { _xhr.setRequestHeader(name, values.join(',')); }); } _xhr.addEventListener('load', onLoad); diff --git a/modules/angular2/src/http/headers.ts b/modules/angular2/src/http/headers.ts index d7362059a6b0d..37ffc71881968 100644 --- a/modules/angular2/src/http/headers.ts +++ b/modules/angular2/src/http/headers.ts @@ -70,7 +70,7 @@ export class Headers { */ delete (name: string): void { MapWrapper.delete(this._headersMap, name); } - forEach(fn: (value: string, name: string, headers: Headers) => any): void { + forEach(fn: (values: string[], name: string, headers: Map) => void): void { MapWrapper.forEach(this._headersMap, fn); } diff --git a/modules/angular2/test/http/backends/xhr_backend_spec.ts b/modules/angular2/test/http/backends/xhr_backend_spec.ts index 027f549e72113..59dfcf644c8cf 100644 --- a/modules/angular2/test/http/backends/xhr_backend_spec.ts +++ b/modules/angular2/test/http/backends/xhr_backend_spec.ts @@ -148,14 +148,16 @@ export function main() { }); it('should attach headers to the request', () => { - var headers = new Headers({'Content-Type': 'text/xml', 'Breaking-Bad': '<3'}); + var headers = + new Headers({'Content-Type': 'text/xml', 'Breaking-Bad': '<3', 'X-Multi': ['a', 'b']}); var base = new BaseRequestOptions(); var connection = new XHRConnection( new Request(base.merge(new RequestOptions({headers: headers}))), new MockBrowserXHR()); connection.response.subscribe(); - expect(setRequestHeaderSpy).toHaveBeenCalledWith('Content-Type', ['text/xml']); - expect(setRequestHeaderSpy).toHaveBeenCalledWith('Breaking-Bad', ['<3']); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Content-Type', 'text/xml'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Breaking-Bad', '<3'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('X-Multi', 'a,b'); }); it('should return the correct status code', inject([AsyncTestCompleter], async => {