diff --git a/modules/@angular/http/src/headers.ts b/modules/@angular/http/src/headers.ts index 9d1f5982a8..553fb34f86 100644 --- a/modules/@angular/http/src/headers.ts +++ b/modules/@angular/http/src/headers.ts @@ -46,7 +46,7 @@ export class Headers { _headersMap: Map; constructor(headers?: Headers|{[key: string]: any}) { if (headers instanceof Headers) { - this._headersMap = (headers)._headersMap; + this._headersMap = new Map((headers)._headersMap); return; } diff --git a/modules/@angular/http/test/headers_spec.ts b/modules/@angular/http/test/headers_spec.ts index 9b79275ee2..ae8593a1ef 100644 --- a/modules/@angular/http/test/headers_spec.ts +++ b/modules/@angular/http/test/headers_spec.ts @@ -42,6 +42,14 @@ export function main() { expect(headers.get('foo')).toBe('bar'); expect(headers.getAll('foo')).toEqual(['bar']); }); + it('should not alter the values of a provided header template', () => { + // Spec at https://fetch.spec.whatwg.org/#concept-headers-fill + // test for https://github.com/angular/angular/issues/6845 + const firstHeaders = new Headers(); + const secondHeaders = new Headers(firstHeaders); + secondHeaders.append('Content-Type', 'image/jpeg'); + expect(firstHeaders.has('Content-Type')).toBeFalsy(); + }); });