fix(http): create a copy of headers when merge options (#13365)
Closes #11980
This commit is contained in:
parent
56dce0e26d
commit
2e500cc85b
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue