@@ -29,11 +29,12 @@ function parseHeaders (headers) {
2929 . map ( ( r ) => r . split ( ':' ) . map ( ( str ) => str . trim ( ) ) )
3030
3131 const object = { }
32- pairs . forEach ( ( [ key , value ] ) => {
33- key = key . toLowerCase ( )
32+ for ( const pair of pairs ) {
33+ const value = pair [ 1 ]
3434 if ( ! value ) {
35- return
35+ continue
3636 }
37+ const key = pair [ 0 ] . toLowerCase ( )
3738 if ( object [ key ] ) {
3839 if ( ! Array . isArray ( object [ key ] ) ) {
3940 object [ key ] = [ object [ key ] , value ]
@@ -43,7 +44,7 @@ function parseHeaders (headers) {
4344 } else {
4445 object [ key ] = value
4546 }
46- } )
47+ }
4748 return object
4849}
4950const channels = {
@@ -106,9 +107,9 @@ function diagnostics (tracer, config) {
106107 ) {
107108 const injectedHeaders = { }
108109 tracer . inject ( span , HTTP_HEADERS , injectedHeaders )
109- Object . entries ( injectedHeaders ) . forEach ( ( [ key , value ] ) => {
110+ for ( const [ key , value ] of Object . entries ( injectedHeaders ) ) {
110111 request . addHeader ( key , value )
111- } )
112+ }
112113 }
113114
114115 analyticsSampler . sample ( span , config . measured )
@@ -143,9 +144,9 @@ function diagnostics (tracer, config) {
143144
144145function addRequestHeaders ( req , span , config ) {
145146 const headers = parseHeaders ( req . headers )
146- Object . entries ( headers ) . forEach ( ( [ key , value ] ) => {
147+ for ( const [ key , value ] of Object . entries ( headers ) ) {
147148 span . setTag ( `${ HTTP_REQUEST_HEADERS } .${ key } ` , value )
148- } )
149+ }
149150
150151 if ( ! headers . host ) {
151152 // req.servername holds the value of the host header
@@ -174,13 +175,12 @@ function setStatusCode (res, span, config) {
174175}
175176
176177function addResponseHeaders ( res , span , config ) {
177- config . headers . forEach ( ( key ) => {
178+ for ( const key of config . headers ) {
178179 const value = res . headers [ key ]
179-
180180 if ( value ) {
181181 span . setTag ( `${ HTTP_RESPONSE_HEADERS } .${ key } ` , value )
182182 }
183- } )
183+ }
184184}
185185
186186function finishSpan ( res , span , error , config ) {
0 commit comments