From a67c06708d5c65dcff5cf9d85edf86fa2074c082 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 5 Oct 2016 16:36:42 -0700 Subject: [PATCH] fix(http): Headers.append should append to the list --- modules/@angular/http/src/headers.ts | 7 ++++++- modules/@angular/http/test/headers_spec.ts | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/@angular/http/src/headers.ts b/modules/@angular/http/src/headers.ts index b656f315a9..0e54e80689 100644 --- a/modules/@angular/http/src/headers.ts +++ b/modules/@angular/http/src/headers.ts @@ -88,7 +88,12 @@ export class Headers { */ append(name: string, value: string): void { const values = this.getAll(name); - this.set(name, values === null ? [value] : [...values, value]); + + if (values === null) { + this.set(name, value); + } else { + values.push(value); + } } /** diff --git a/modules/@angular/http/test/headers_spec.ts b/modules/@angular/http/test/headers_spec.ts index 2a1f8068bf..0325f0c5ab 100644 --- a/modules/@angular/http/test/headers_spec.ts +++ b/modules/@angular/http/test/headers_spec.ts @@ -111,6 +111,14 @@ export function main() { }); describe('.append', () => { + it('should append a value to the list', () => { + const headers = new Headers(); + headers.append('foo', 'bar'); + headers.append('foo', 'baz'); + expect(headers.get('foo')).toEqual('bar'); + expect(headers.getAll('foo')).toEqual(['bar', 'baz']); + }); + it('should preserve the case of the first call', () => { const headers = new Headers();