@@ -23,8 +23,7 @@ export class HttpHeaders {
2323 /**
2424 * Internal map of lowercase header names to values.
2525 */
26- // TODO(issue/24571): remove '!'.
27- private headers ! : Map < string , string [ ] > ;
26+ private headers : Map < string , string [ ] > = new Map ( ) ;
2827
2928 /**
3029 * Internal map of lowercased header names to the normalized
@@ -47,11 +46,9 @@ export class HttpHeaders {
4746 constructor (
4847 headers ?: string | { [ name : string ] : string | number | ( string | number ) [ ] } | Headers ,
4948 ) {
50- if ( ! headers ) {
51- this . headers = new Map < string , string [ ] > ( ) ;
52- } else if ( typeof headers === 'string' ) {
49+ if ( ! headers ) return ;
50+ if ( typeof headers === 'string' ) {
5351 this . lazyInit = ( ) => {
54- this . headers = new Map < string , string [ ] > ( ) ;
5552 headers . split ( '\n' ) . forEach ( ( line ) => {
5653 const index = line . indexOf ( ':' ) ;
5754 if ( index > 0 ) {
@@ -62,7 +59,6 @@ export class HttpHeaders {
6259 } ) ;
6360 } ;
6461 } else if ( typeof Headers !== 'undefined' && headers instanceof Headers ) {
65- this . headers = new Map < string , string [ ] > ( ) ;
6662 headers . forEach ( ( value : string , name : string ) => {
6763 this . addHeaderEntry ( name , value ) ;
6864 } ) ;
@@ -71,7 +67,6 @@ export class HttpHeaders {
7167 if ( typeof ngDevMode === 'undefined' || ngDevMode ) {
7268 assertValidHeaders ( headers ) ;
7369 }
74- this . headers = new Map < string , string [ ] > ( ) ;
7570 Object . entries ( headers ) . forEach ( ( [ name , values ] ) => {
7671 this . setHeaderEntries ( name , values ) ;
7772 } ) ;
0 commit comments