@@ -18,6 +18,7 @@ use iron::headers::{AcceptEncoding, ContentEncoding, Encoding, QualityItem};
18
18
use iron:: method;
19
19
use iron:: modifiers:: Redirect ;
20
20
use iron:: status;
21
+ use iron:: status:: Status ;
21
22
use iron:: { Chain , Handler , Iron , IronError , IronResult , Request , Response , Set } ;
22
23
use iron_cors:: CorsMiddleware ;
23
24
use lazy_static:: lazy_static;
@@ -509,7 +510,7 @@ impl Handler for MainHandler {
509
510
io:: ErrorKind :: NotFound => {
510
511
if let Some ( ref p) = self . try_file_404 {
511
512
if Some ( true ) == fs:: metadata ( p) . ok ( ) . map ( |meta| meta. is_file ( ) ) {
512
- return self . send_file ( req, p) ;
513
+ return self . send_file ( req, p, Some ( status :: NotFound ) ) ;
513
514
}
514
515
}
515
516
status:: NotFound
@@ -527,7 +528,7 @@ impl Handler for MainHandler {
527
528
. collect ( ) ;
528
529
self . list_directory ( req, & fs_path, & path_prefix, & self . base_url [ ..] )
529
530
} else {
530
- self . send_file ( req, & fs_path)
531
+ self . send_file ( req, & fs_path, None )
531
532
}
532
533
}
533
534
}
@@ -776,7 +777,7 @@ impl MainHandler {
776
777
if filename == * fname {
777
778
// Automatic render index page
778
779
fs_path. push ( filename) ;
779
- return self . send_file ( req, & fs_path) ;
780
+ return self . send_file ( req, & fs_path, None ) ;
780
781
}
781
782
}
782
783
}
@@ -884,7 +885,12 @@ impl MainHandler {
884
885
Ok ( resp)
885
886
}
886
887
887
- fn send_file < P : AsRef < Path > > ( & self , req : & Request , path : P ) -> IronResult < Response > {
888
+ fn send_file < P : AsRef < Path > > (
889
+ & self ,
890
+ req : & Request ,
891
+ path : P ,
892
+ status : Option < Status > ,
893
+ ) -> IronResult < Response > {
888
894
use filetime:: FileTime ;
889
895
use iron:: headers:: {
890
896
AcceptRanges , ByteRangeSpec , ContentLength , ContentRange , ContentRangeSpec , ETag ,
@@ -907,7 +913,7 @@ impl MainHandler {
907
913
modified. nsec
908
914
) ) ;
909
915
910
- let mut resp = Response :: with ( status:: Ok ) ;
916
+ let mut resp = Response :: with ( status. unwrap_or ( status :: Ok ) ) ;
911
917
if self . range {
912
918
resp. headers . set ( AcceptRanges ( vec ! [ RangeUnit :: Bytes ] ) ) ;
913
919
}
0 commit comments