File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -155,4 +155,30 @@ describe('when proxy request is a GET', function () {
155155 . end ( done ) ;
156156 } ) ;
157157
158+ it ( 'should use proxyReqBodyDecorator with parseReqBody=false' , function ( done ) {
159+ var scope = nock ( 'http://127.0.0.1:12345' )
160+ . get ( '/' , { } )
161+ . matchHeader ( 'Content-Type' , 'application/json' )
162+ . reply ( 200 , {
163+ name : 'proxyReqBodyDecorator + parseReqBody=false works'
164+ } ) ;
165+
166+ var payload = { } ;
167+
168+ localServer . use ( '/proxy' , proxy ( 'http://127.0.0.1:12345' , {
169+ parseReqBody : false ,
170+ proxyReqBodyDecorator : ( ) => JSON . stringify ( payload ) ,
171+ } ) ) ;
172+
173+ request ( localServer )
174+ . get ( '/proxy' )
175+ . send ( payload )
176+ . set ( 'Content-Type' , 'application/json' )
177+ . expect ( function ( res ) {
178+ assert ( res . body . name === 'proxyReqBodyDecorator + parseReqBody=false works' ) ;
179+ scope . done ( ) ;
180+ } )
181+ . end ( done ) ;
182+ } ) ;
183+
158184} ) ;
Original file line number Diff line number Diff line change @@ -128,4 +128,30 @@ describe('when proxy request is a POST', function () {
128128 . end ( done ) ;
129129 } ) ;
130130
131+ it ( 'should use proxyReqBodyDecorator with parseReqBody=false' , function ( done ) {
132+ var scope = nock ( 'http://127.0.0.1:12345' )
133+ . post ( '/' , { } )
134+ . matchHeader ( 'Content-Type' , 'application/json' )
135+ . reply ( 200 , {
136+ name : 'proxyReqBodyDecorator + parseReqBody=false works'
137+ } ) ;
138+
139+ var payload = { } ;
140+
141+ localServer . use ( '/proxy' , proxy ( 'http://127.0.0.1:12345' , {
142+ parseReqBody : false ,
143+ proxyReqBodyDecorator : ( ) => JSON . stringify ( payload ) ,
144+ } ) ) ;
145+
146+ request ( localServer )
147+ . post ( '/proxy' )
148+ . send ( payload )
149+ . set ( 'Content-Type' , 'application/json' )
150+ . expect ( function ( res ) {
151+ assert ( res . body . name === 'proxyReqBodyDecorator + parseReqBody=false works' ) ;
152+ scope . done ( ) ;
153+ } )
154+ . end ( done ) ;
155+ } ) ;
156+
131157} ) ;
You can’t perform that action at this time.
0 commit comments