File tree 1 file changed +37
-0
lines changed
1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -872,6 +872,43 @@ describe('compression()', function () {
872
872
. end ( )
873
873
} )
874
874
875
+ it ( 'should invoke flush callback when supplied for brotli' , function ( done ) {
876
+ var chunks = 0 , callbackInvoked = false ;
877
+ var resp
878
+ var server = createServer ( { threshold : 0 } , function ( req , res ) {
879
+ resp = res
880
+ res . setHeader ( 'Content-Type' , 'text/plain' )
881
+ write ( )
882
+ } )
883
+
884
+ function flushCallback ( ) {
885
+ callbackInvoked = true ;
886
+ }
887
+
888
+ function write ( ) {
889
+ chunks ++
890
+ if ( chunks === 20 ) return resp . end ( )
891
+ if ( chunks > 20 ) return chunks --
892
+ resp . write ( '..' )
893
+ resp . flush ( flushCallback )
894
+ }
895
+
896
+ request ( server )
897
+ . get ( '/' )
898
+ . set ( 'Accept-Encoding' , 'br' )
899
+ . request ( )
900
+ . on ( 'response' , function ( res ) {
901
+ assert . equal ( res . headers [ 'content-encoding' ] , 'br' )
902
+ res . on ( 'data' , write )
903
+ res . on ( 'end' , function ( ) {
904
+ assert . equal ( chunks , 20 )
905
+ assert . equal ( callbackInvoked , true )
906
+ done ( )
907
+ } )
908
+ } )
909
+ . end ( )
910
+ } )
911
+
875
912
it ( 'should invoke flush callback when supplied for deflate' , function ( done ) {
876
913
var chunks = 0 , callbackInvoked = false ;
877
914
var resp
You can’t perform that action at this time.
0 commit comments