diff --git a/modules/@angular/http/src/headers.ts b/modules/@angular/http/src/headers.ts index 3e582aa239..03906fb3a3 100644 --- a/modules/@angular/http/src/headers.ts +++ b/modules/@angular/http/src/headers.ts @@ -49,7 +49,7 @@ export class Headers { } if (headers instanceof Headers) { - headers._headers.forEach((values: string[], name: string) => { + headers.forEach((values: string[], name: string) => { values.forEach(value => this.append(name, value)); }); return; diff --git a/modules/@angular/http/test/backends/xhr_backend_spec.ts b/modules/@angular/http/test/backends/xhr_backend_spec.ts index 03ee41174d..24edc410e3 100644 --- a/modules/@angular/http/test/backends/xhr_backend_spec.ts +++ b/modules/@angular/http/test/backends/xhr_backend_spec.ts @@ -233,9 +233,9 @@ export function main() { 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('x-multi', 'a,b'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Content-Type', 'text/xml'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Breaking-Bad', '<3'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('X-Multi', 'a,b'); }); it('should skip content type detection if custom content type header is set', () => { @@ -246,7 +246,8 @@ export function main() { new Request(base.merge(new RequestOptions({body: body, headers: headers}))), new MockBrowserXHR()); connection.response.subscribe(); - expect(setRequestHeaderSpy).toHaveBeenCalledWith('content-type', 'text/plain'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Content-Type', 'text/plain'); + expect(setRequestHeaderSpy).not.toHaveBeenCalledWith('Content-Type', 'application/json'); expect(setRequestHeaderSpy).not.toHaveBeenCalledWith('content-type', 'application/json'); }); @@ -355,7 +356,7 @@ export function main() { new MockBrowserXHR()); connection.response.subscribe(); expect(sendSpy).toHaveBeenCalledWith(body); - expect(setRequestHeaderSpy).toHaveBeenCalledWith('content-type', 'text/css'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Content-Type', 'text/css'); }); it('should use array buffer body to the request', () => { @@ -386,7 +387,7 @@ export function main() { new MockBrowserXHR()); connection.response.subscribe(); expect(sendSpy).toHaveBeenCalledWith(body); - expect(setRequestHeaderSpy).toHaveBeenCalledWith('content-type', 'text/css'); + expect(setRequestHeaderSpy).toHaveBeenCalledWith('Content-Type', 'text/css'); }); } diff --git a/modules/@angular/http/test/headers_spec.ts b/modules/@angular/http/test/headers_spec.ts index d1090b82ee..64107463c3 100644 --- a/modules/@angular/http/test/headers_spec.ts +++ b/modules/@angular/http/test/headers_spec.ts @@ -76,6 +76,13 @@ export function main() { expect(JSON.stringify(headers)).toEqual('{"fOo":["bat"]}'); }); + it('should preserve cases after cloning', () => { + const headers = new Headers(); + headers.set('fOo', 'baz'); + headers.set('foo', 'bat'); + expect(JSON.stringify(new Headers(headers))).toEqual('{"fOo":["bat"]}'); + }); + it('should convert input array to string', () => { const headers = new Headers(); headers.set('foo', ['bar', 'baz']);