@@ -103,6 +103,40 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
103103 expect ( response ) . toEqual ( expectedResponse )
104104 } )
105105
106+ test ( 'headers get lowercased' , async ( ) => {
107+ app = express ( )
108+ router = express . Router ( )
109+ app . use ( '/' , router )
110+ serverlessExpressInstance = serverlessExpress ( { app } )
111+ router . get ( '/foo' , ( req , res ) => {
112+ const xHeaders = Object . fromEntries (
113+ Object . entries ( req . headers ) . filter ( ( [ name ] ) => name . startsWith ( 'x-header-' ) )
114+ )
115+ res . json ( { xHeaders } )
116+ } )
117+ const event = makeEvent ( {
118+ eventSourceName : 'apiGatewayV1' ,
119+ path : '/foo' ,
120+ httpMethod : 'GET' ,
121+ multiValueHeaders : undefined ,
122+ headers : {
123+ 'X-Header-One' : 'Value1' ,
124+ 'x-header-two' : 'Value2'
125+ }
126+ } )
127+ const response = await serverlessExpressInstance ( event )
128+ const expectedResponse = makeResponse ( {
129+ eventSourceName : 'apiGatewayV1' ,
130+ body : JSON . stringify ( {
131+ xHeaders : {
132+ 'x-header-one' : 'Value1' ,
133+ 'x-header-two' : 'Value2'
134+ }
135+ } )
136+ } )
137+ expect ( response ) . toMatchObject ( expectedResponse )
138+ } )
139+
106140 test ( 'resolutionMode = CALLBACK' , ( done ) => {
107141 const jsonResponse = { data : { name : 'Brett' } }
108142 router . get ( '/users' , ( req , res ) => {
@@ -287,7 +321,7 @@ describe.each(EACH_MATRIX)('%s:%s: integration tests', (eventSourceName, framewo
287321 const response = await serverlessExpressInstance ( event )
288322 const expectedResponse = makeResponse ( {
289323 eventSourceName,
290- body : JSON . stringify ( { data : { name : name } } ) ,
324+ body : JSON . stringify ( { data : { name } } ) ,
291325 multiValueHeaders : {
292326 'content-length' : [ '29' ] ,
293327 etag : [ 'W/"1d-9ERga12t1e/5eBdg3k9zfIvAfWo"' ]
0 commit comments