File tree Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Expand file tree Collapse file tree 1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,12 @@ use time::OffsetDateTime;
7
7
8
8
pub struct Static {
9
9
path : PathBuf ,
10
- types : mime:: Types ,
11
10
}
12
11
13
12
impl Static {
14
13
pub fn new < P : AsRef < Path > > ( path : P ) -> Static {
15
14
Static {
16
15
path : path. as_ref ( ) . to_path_buf ( ) ,
17
- types : mime:: Types :: new ( ) . expect ( "Couldn't load mime-types" ) ,
18
16
}
19
17
}
20
18
}
@@ -27,7 +25,7 @@ impl Handler for Static {
27
25
}
28
26
29
27
let path = self . path . join ( request_path) ;
30
- let mime = self . types . mime_for_path ( & path) ;
28
+ let mime = mime :: mime_for_path ( & path) . unwrap_or ( "application/octet-stream" ) ;
31
29
let file = match File :: open ( & path) {
32
30
Ok ( f) => f,
33
31
Err ( ..) => return Ok ( not_found ( ) ) ,
@@ -80,7 +78,7 @@ mod tests {
80
78
let res = handler. call ( & mut req) . expect ( "No response" ) ;
81
79
assert_eq ! (
82
80
res. headers( ) . get( header:: CONTENT_TYPE ) . unwrap( ) ,
83
- "text/plain "
81
+ "application/toml "
84
82
) ;
85
83
assert_eq ! ( res. headers( ) . get( header:: CONTENT_LENGTH ) . unwrap( ) , "9" ) ;
86
84
assert_eq ! ( * res. into_cow( ) , b"[package]" [ ..] ) ;
You can’t perform that action at this time.
0 commit comments