Skip to content

Commit 0f138c5

Browse files
committed
Return content-type header on directory default
Signed-off-by: itowlson <[email protected]>
1 parent d1fefaa commit 0f138c5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lib.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,20 @@ impl FileServer {
381381

382382
/// Return the media type of the file based on the path.
383383
fn mime(path: &str) -> Option<String> {
384-
match path {
384+
let mut mime = match path {
385385
FAVICON_ICO_FILENAME => mime_guess::from_ext("ico"),
386386
FAVICON_PNG_FILENAME => mime_guess::from_ext("png"),
387387
_ => mime_guess::from_path(path),
388388
}
389-
.first()
390-
.map(|m| m.to_string())
389+
.first();
390+
391+
if mime.is_none() {
392+
if let FileServerPath::Physical(p) = Self::resolve(path) {
393+
mime = mime_guess::from_path(&p).first();
394+
}
395+
}
396+
397+
mime.map(|m| m.to_string())
391398
}
392399

393400
fn make_headers(path: &str, enc: SupportedEncoding, etag: &str) -> Vec<(String, Vec<u8>)> {

0 commit comments

Comments
 (0)