File tree 2 files changed +22
-0
lines changed
tower-http/src/services/fs/serve_dir
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change
1
+ Content.
Original file line number Diff line number Diff line change @@ -275,6 +275,27 @@ async fn precompressed_without_extension() {
275
275
assert ! ( decompressed. starts_with( "Content." ) ) ;
276
276
}
277
277
278
+ #[ tokio:: test]
279
+ async fn missing_precompressed_without_extension_fallbacks_to_uncompressed ( ) {
280
+ let svc = ServeDir :: new ( "../test-files" ) . precompressed_gzip ( ) ;
281
+
282
+ let request = Request :: builder ( )
283
+ . uri ( "/extensionless_precompressed_missing" )
284
+ . header ( "Accept-Encoding" , "gzip" )
285
+ . body ( Body :: empty ( ) )
286
+ . unwrap ( ) ;
287
+ let res = svc. oneshot ( request) . await . unwrap ( ) ;
288
+
289
+ assert_eq ! ( res. status( ) , StatusCode :: OK ) ;
290
+
291
+ assert_eq ! ( res. headers( ) [ "content-type" ] , "application/octet-stream" ) ;
292
+ assert ! ( res. headers( ) . get( "content-encoding" ) . is_none( ) ) ;
293
+
294
+ let body = res. into_body ( ) . collect ( ) . await . unwrap ( ) . to_bytes ( ) ;
295
+ let body = String :: from_utf8 ( body. to_vec ( ) ) . unwrap ( ) ;
296
+ assert ! ( body. starts_with( "Content." ) ) ;
297
+ }
298
+
278
299
#[ tokio:: test]
279
300
async fn access_to_sub_dirs ( ) {
280
301
let svc = ServeDir :: new ( ".." ) ;
You can’t perform that action at this time.
0 commit comments