File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -467,8 +467,8 @@ impl BufRead for Body {
467
467
/// This is used for various binary formats such as images and videos.
468
468
#[ cfg( feature = "async_std" ) ]
469
469
async fn peek_mime ( file : & mut async_std:: fs:: File ) -> io:: Result < Option < Mime > > {
470
- // Reading the first 8 bytes should be enough to sniff the mime type .
471
- let mut buf = [ 0_u8 ; 8 ] ;
470
+ // We need to read the first 300 bytes to correctly infer formats such as tar .
471
+ let mut buf = [ 0_u8 ; 300 ] ;
472
472
file. read ( & mut buf) . await ?;
473
473
let mime = Mime :: sniff ( & buf) . ok ( ) ;
474
474
@@ -484,11 +484,10 @@ fn guess_ext(path: &Path) -> Option<Mime> {
484
484
let ext = path. extension ( ) . map ( |p| p. to_str ( ) ) . flatten ( ) ;
485
485
match ext {
486
486
Some ( "html" ) => Some ( mime:: HTML ) ,
487
- Some ( "js" ) | Some ( "mjs" ) => Some ( mime:: JAVASCRIPT ) ,
487
+ Some ( "js" ) | Some ( "mjs" ) | Some ( "jsonp" ) => Some ( mime:: JAVASCRIPT ) ,
488
488
Some ( "json" ) => Some ( mime:: JSON ) ,
489
489
Some ( "css" ) => Some ( mime:: CSS ) ,
490
490
Some ( "svg" ) => Some ( mime:: SVG ) ,
491
- Some ( "wasm" ) => Some ( mime:: WASM ) ,
492
491
None | Some ( _) => None ,
493
492
}
494
493
}
You can’t perform that action at this time.
0 commit comments