@@ -130,6 +130,25 @@ function verifyLoadingFailed({ method, params }) {
130130 assert . strictEqual ( typeof params . errorText , 'string' ) ;
131131}
132132
133+ function verifyHttpResponse ( response ) {
134+ assert . strictEqual ( response . statusCode , 200 ) ;
135+ const chunks = [ ] ;
136+
137+ // Verifies that the inspector does not put the response into flowing mode.
138+ assert . strictEqual ( response . readableFlowing , null ) ;
139+ queueMicrotask ( ( ) => {
140+ response . on ( 'data' , ( chunk ) => {
141+ chunks . push ( chunk ) ;
142+ } ) ;
143+ assert . strictEqual ( response . readableFlowing , true ) ;
144+ } ) ;
145+
146+ response . on ( 'end' , common . mustCall ( ( ) => {
147+ const body = Buffer . concat ( chunks ) . toString ( ) ;
148+ assert . strictEqual ( body , '\nhello world\n' ) ;
149+ } ) ) ;
150+ }
151+
133152async function testHttpGet ( ) {
134153 const url = `http://127.0.0.1:${ httpServer . address ( ) . port } /hello-world` ;
135154 const requestWillBeSentFuture = once ( session , 'Network.requestWillBeSent' )
@@ -146,18 +165,20 @@ async function testHttpGet() {
146165 port : httpServer . address ( ) . port ,
147166 path : '/hello-world' ,
148167 headers : requestHeaders
149- } , common . mustCall ( ( res ) => {
150- // Dump the response.
151- res . on ( 'data' , ( ) => { } ) ;
152- res . on ( 'end' , ( ) => { } ) ;
153- } ) ) ;
168+ } , common . mustCall ( verifyHttpResponse ) ) ;
154169
155170 await requestWillBeSentFuture ;
156171 const responseReceived = await responseReceivedFuture ;
157172 const loadingFinished = await loadingFinishedFuture ;
158173
159174 const delta = ( loadingFinished . timestamp - responseReceived . timestamp ) * 1000 ;
160175 assert . ok ( delta > kDelta ) ;
176+
177+ const responseBody = await session . post ( 'Network.getResponseBody' , {
178+ requestId : responseReceived . requestId ,
179+ } ) ;
180+ assert . strictEqual ( responseBody . base64Encoded , false ) ;
181+ assert . strictEqual ( responseBody . body , '\nhello world\n' ) ;
161182}
162183
163184async function testHttpsGet ( ) {
@@ -177,18 +198,20 @@ async function testHttpsGet() {
177198 path : '/hello-world' ,
178199 rejectUnauthorized : false ,
179200 headers : requestHeaders ,
180- } , common . mustCall ( ( res ) => {
181- // Dump the response.
182- res . on ( 'data' , ( ) => { } ) ;
183- res . on ( 'end' , ( ) => { } ) ;
184- } ) ) ;
201+ } , common . mustCall ( verifyHttpResponse ) ) ;
185202
186203 await requestWillBeSentFuture ;
187204 const responseReceived = await responseReceivedFuture ;
188205 const loadingFinished = await loadingFinishedFuture ;
189206
190207 const delta = ( loadingFinished . timestamp - responseReceived . timestamp ) * 1000 ;
191208 assert . ok ( delta > kDelta ) ;
209+
210+ const responseBody = await session . post ( 'Network.getResponseBody' , {
211+ requestId : responseReceived . requestId ,
212+ } ) ;
213+ assert . strictEqual ( responseBody . base64Encoded , false ) ;
214+ assert . strictEqual ( responseBody . body , '\nhello world\n' ) ;
192215}
193216
194217async function testHttpError ( ) {
0 commit comments