Skip to content

Commit e17731e

Browse files
committed
update with feedback from review
1 parent 0afeb04 commit e17731e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/body.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ impl BufRead for Body {
467467
/// This is used for various binary formats such as images and videos.
468468
#[cfg(feature = "async_std")]
469469
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];
472472
file.read(&mut buf).await?;
473473
let mime = Mime::sniff(&buf).ok();
474474

@@ -484,11 +484,10 @@ fn guess_ext(path: &Path) -> Option<Mime> {
484484
let ext = path.extension().map(|p| p.to_str()).flatten();
485485
match ext {
486486
Some("html") => Some(mime::HTML),
487-
Some("js") | Some("mjs") => Some(mime::JAVASCRIPT),
487+
Some("js") | Some("mjs") | Some("jsonp") => Some(mime::JAVASCRIPT),
488488
Some("json") => Some(mime::JSON),
489489
Some("css") => Some(mime::CSS),
490490
Some("svg") => Some(mime::SVG),
491-
Some("wasm") => Some(mime::WASM),
492491
None | Some(_) => None,
493492
}
494493
}

0 commit comments

Comments
 (0)