@@ -39,6 +39,16 @@ api.get('/testJSONP', function(req,res) {
39
res . status ( 200 ) . html ( { method : 'get' , status : 'ok' } )
39
res . status ( 200 ) . html ( { method : 'get' , status : 'ok' } )
40
} )
40
} )
41
41
42
+ api . get ( '/getHeader' , function ( req , res ) {
43
+ res . status ( 200 ) . header ( 'TestHeader' , 'test' )
44
+ res . json ( {
45
+ headers : res . getHeader ( ) ,
46
+ typeHeader : res . getHeader ( 'TestHeader' ) ,
47
+ typeHeaderCase : res . getHeader ( 'coNtEnt-TyPe' ) ,
48
+ typeHeaderMissing : res . getHeader ( 'test' )
49
+ } )
50
+ } )
51
+
42
52
43
/******************************************************************************/
53
/******************************************************************************/
44
/*** BEGIN TESTS ***/
54
/*** BEGIN TESTS ***/
@@ -76,4 +86,22 @@ describe('Header Tests:', function() {
76
} )
86
} )
77
} ) // end it
87
} ) // end it
78
88
89
+
90
+ it ( 'Get Header' , function ( ) {
91
+ let _event = Object . assign ( { } , event , { path : '/getHeader' } )
92
+
93
+ return new Promise ( ( resolve , reject ) => {
94
+ api . run ( _event , { } , function ( err , res ) { resolve ( res ) } )
95
+ } ) . then ( ( result ) => {
96
+ expect ( result ) . to . deep . equal ( {
97
+ headers : {
98
+ 'Content-Type' : 'application/json' ,
99
+ 'TestHeader' : 'test'
100
+ } , statusCode : 200 ,
101
+ body : '{"headers":{"Content-Type":"application/json","TestHeader":"test"},"typeHeader":"test","typeHeaderCase":"application/json","typeHeaderMissing":null}' ,
102
+ isBase64Encoded : false
103
+ } )
104
+ } )
105
+ } ) // end it
106
+
79
} ) // end HEADER tests
107
} ) // end HEADER tests
0 commit comments