diff --git a/modules/@angular/http/src/base_request_options.ts b/modules/@angular/http/src/base_request_options.ts index b844a6c308..2418627f5e 100644 --- a/modules/@angular/http/src/base_request_options.ts +++ b/modules/@angular/http/src/base_request_options.ts @@ -121,7 +121,7 @@ export class RequestOptions { merge(options?: RequestOptionsArgs): RequestOptions { return new RequestOptions({ method: options && options.method != null ? options.method : this.method, - headers: options && options.headers != null ? options.headers : this.headers, + headers: options && options.headers != null ? options.headers : new Headers(this.headers), body: options && options.body != null ? options.body : this.body, url: options && options.url != null ? options.url : this.url, params: options && this._mergeSearchParams(options.params || options.search), diff --git a/modules/@angular/http/test/base_request_options_spec.ts b/modules/@angular/http/test/base_request_options_spec.ts index 4f70e04fc7..195e63f277 100644 --- a/modules/@angular/http/test/base_request_options_spec.ts +++ b/modules/@angular/http/test/base_request_options_spec.ts @@ -9,6 +9,7 @@ import {describe, expect, it} from '@angular/core/testing/testing_internal'; import {BaseRequestOptions, RequestOptions} from '../src/base_request_options'; import {RequestMethod} from '../src/enums'; +import {Headers} from '../src/headers'; export function main() { describe('BaseRequestOptions', () => { @@ -45,5 +46,11 @@ export function main() { expect(options2.params.paramsMap.get('b')).toEqual(['text']); expect(options2.params.paramsMap.get('c')).toEqual(['1', '2', '3']); }); + + it('should create a new headers object when calling merge', () => { + const options1 = new RequestOptions({headers: new Headers()}); + const options2 = options1.merge(); + expect(options2.headers).not.toBe(options1.headers); + }); }); }