@@ -329,11 +329,15 @@ describe('compression()', function () {
329
329
request . on ( 'response' , function ( headers ) {
330
330
assert . strictEqual ( headers [ 'content-encoding' ] , 'gzip' )
331
331
} )
332
+ var chunks = [ ] ;
332
333
request . on ( 'data' , function ( chunk ) {
333
- // no-op without which the request will stay open and cause a test timeout
334
+ chunks . push ( chunk ) ;
334
335
} )
335
336
request . on ( 'end' , function ( ) {
336
- closeHttp2 ( request , client , server , done )
337
+ zlib . gunzip ( Buffer . concat ( chunks ) , function ( err , data ) {
338
+ assert . strictEqual ( data . toString ( ) , 'hello, world' )
339
+ closeHttp2 ( client , server , done )
340
+ } )
337
341
} )
338
342
request . end ( )
339
343
} )
@@ -730,27 +734,23 @@ function createHttp2Client (port) {
730
734
return http2 . connect ( 'http://127.0.0.1:' + port )
731
735
}
732
736
733
- function closeHttp2 ( request , client , server , callback ) {
737
+ function closeHttp2 ( client , server , callback ) {
734
738
if ( typeof client . shutdown === 'function' ) {
735
739
// this is the node v8.x way of closing the connections
736
- request . destroy ( http2 . constants . NGHTTP2_NO_ERROR , function ( ) {
737
740
client . shutdown ( { } , function ( ) {
738
741
server . close ( function ( ) {
739
742
callback ( )
740
743
} )
741
744
} )
742
- } )
743
745
} else {
744
746
// this is the node v9.x onwards way of closing the connections
745
- request . close ( http2 . constants . NGHTTP2_NO_ERROR , function ( ) {
746
747
client . close ( function ( ) {
747
748
// force existing connections to time out after 1ms.
748
749
// this is done to force the server to close in some cases where it wouldn't do it otherwise.
749
750
server . close ( function ( ) {
750
751
callback ( )
751
752
} )
752
753
} )
753
- } )
754
754
}
755
755
}
756
756
0 commit comments