File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -120,6 +120,16 @@ async fn file_response(path: &Path) -> http::Response<Body> {
120
120
log:: info!( "Invalid file name: `{}`" , path. display( ) ) ;
121
121
return error:: from_status ( http:: StatusCode :: NOT_FOUND ) ;
122
122
}
123
+ #[ cfg( windows) ]
124
+ Err ( err) if err. raw_os_error ( ) == Some ( 5 ) && path. is_dir ( ) => {
125
+ log:: info!( "Path is a directory: `{}`" , path. display( ) ) ;
126
+ return error:: from_status ( http:: StatusCode :: NOT_FOUND ) ;
127
+ }
128
+ #[ cfg( unix) ]
129
+ Err ( err) if err. raw_os_error ( ) == Some ( 21 ) => {
130
+ log:: info!( "Path is a directory: `{}`" , path. display( ) ) ;
131
+ return error:: from_status ( http:: StatusCode :: NOT_FOUND ) ;
132
+ }
123
133
Err ( err) => {
124
134
log:: error!( "Error opening file: {}" , err) ;
125
135
return error:: from_status ( http:: StatusCode :: INTERNAL_SERVER_ERROR ) ;
You can’t perform that action at this time.
0 commit comments