@@ -1106,9 +1106,10 @@ describe('send(file, options)', function(){
11061106 . expect ( 'Vary' , 'Accept-Encoding' , done )
11071107 } )
11081108
1109- it ( 'should send brotli when present with equal weight in accept-encoding' , function ( done ) {
1109+ it ( 'should prefer server encoding order (br,gzip) when present with equal weight in accept-encoding' , function ( done ) {
11101110 var app = http . createServer ( function ( req , res ) {
1111- send ( req , req . url , { precompressed : true , root : fixtures } )
1111+ send ( req , req . url , { precompressed : [ { encoding : 'br' , extension : '.br' } ,
1112+ { encoding : 'gzip' , extension : '.gz' } ] , root : fixtures } )
11121113 . pipe ( res ) ;
11131114 } ) ;
11141115
@@ -1121,35 +1122,35 @@ describe('send(file, options)', function(){
11211122 . expect ( 'Content-Length' , '15' , done )
11221123 } )
11231124
1124- it ( 'should send gzip when preferred in accept-encoding' , function ( done ) {
1125+ it ( 'should prefer server encoding order ( gzip,br) when present with equal weight in accept-encoding' , function ( done ) {
11251126 var app = http . createServer ( function ( req , res ) {
1126- send ( req , req . url , { precompressed : true , root : fixtures } )
1127+ send ( req , req . url , { precompressed : [ { encoding : 'gzip' , extension : '.gz' } ,
1128+ { encoding : 'br' , extension : '.br' } ] , root : fixtures } )
11271129 . pipe ( res ) ;
11281130 } ) ;
11291131
11301132 request ( app )
11311133 . get ( '/name.html' )
1132- . set ( 'Accept-Encoding' , ' gzip , deflate' )
1134+ . set ( 'Accept-Encoding' , 'br , deflate, gzip ' )
11331135 . expect ( 'Vary' , 'Accept-Encoding' )
11341136 . expect ( 'Content-Encoding' , 'gzip' )
11351137 . expect ( 'Content-Type' , 'text/html; charset=UTF-8' )
11361138 . expect ( 'Content-Length' , '31' , done )
11371139 } )
11381140
1139- it ( 'should honor explicit precompression format configuration ' , function ( done ) {
1141+ it ( 'should send gzip when preferred in accept-encoding ' , function ( done ) {
11401142 var app = http . createServer ( function ( req , res ) {
1141- send ( req , req . url , { precompressed : [ { encoding : 'fake' , extension : '' } ,
1142- { encoding : 'gzip' , extension : '.gz' } ] , root : fixtures } )
1143+ send ( req , req . url , { precompressed : true , root : fixtures } )
11431144 . pipe ( res ) ;
11441145 } ) ;
11451146
11461147 request ( app )
11471148 . get ( '/name.html' )
1148- . set ( 'Accept-Encoding' , 'gzip, fake ' )
1149+ . set ( 'Accept-Encoding' , ' gzip , deflate ' )
11491150 . expect ( 'Vary' , 'Accept-Encoding' )
1150- . expect ( 'Content-Encoding' , 'fake ' )
1151+ . expect ( 'Content-Encoding' , 'gzip ' )
11511152 . expect ( 'Content-Type' , 'text/html; charset=UTF-8' )
1152- . expect ( 'Content-Length' , '11 ' , done )
1153+ . expect ( 'Content-Length' , '31 ' , done )
11531154 } )
11541155
11551156 it ( 'should not send gzip when no-gzip encoding is used' , function ( done ) {
@@ -1220,7 +1221,8 @@ describe('send(file, options)', function(){
12201221
12211222 it ( 'should return server preferred format for accept-encoding *' , function ( done ) {
12221223 var app = http . createServer ( function ( req , res ) {
1223- send ( req , req . url , { precompressed : true , root : fixtures } )
1224+ send ( req , req . url , { precompressed : [ { encoding : 'br' , extension : '.br' } ,
1225+ { encoding : 'gzip' , extension : '.gz' } ] , root : fixtures } )
12241226 . pipe ( res ) ;
12251227 } ) ;
12261228
0 commit comments