diff --git a/src/ops.rs b/src/ops.rs index b62cbdc..71ddf76 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -133,7 +133,7 @@ impl HttpHandler { fn handle_put(&self, req: &mut Request) -> IronResult { if self.temp_directory.is_none() { - return self.handle_bad_method(req); + return self.handle_forbidden_method(req, "-w", "write requests"); } let (req_p, _, url_err) = self.parse_requested_path(req); @@ -221,7 +221,7 @@ impl HttpHandler { fn handle_delete(&self, req: &mut Request) -> IronResult { if self.temp_directory.is_none() { - return self.handle_bad_method(req); + return self.handle_forbidden_method(req, "-w", "write requests"); } let (req_p, symlink, url_err) = self.parse_requested_path(req); @@ -264,6 +264,20 @@ impl HttpHandler { }) } + fn handle_forbidden_method(&self, req: &mut Request, switch: &str, desc: &str) -> IronResult { + println!("{} used disabled request method {} grouped under {}", req.remote_addr, req.method, desc); + Ok(Response::with((status::Forbidden, + Header(headers::Server(USER_AGENT.to_string())), + "text/html;charset=utf-8".parse::().unwrap(), + html_response(ERROR_HTML, + &["403 Forbidden", + "This feature is currently disabled.", + &format!("

Ask the server administrator to pass {} \ + to the executable to enable support for {}.

", + switch, + desc)])))) + } + fn handle_bad_method(&self, req: &mut Request) -> IronResult { println!("{} used invalid request method {}", req.remote_addr, req.method); Ok(Response::with((status::NotImplemented,