From 6bff50ed55b015dc005f623ee57bb74babdc2b93 Mon Sep 17 00:00:00 2001 From: Snorre Ettrup Altschul Date: Wed, 26 Mar 2025 20:12:49 +0100 Subject: [PATCH] stuff --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 62568fe..026ed43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,6 +77,9 @@ impl Request { cwd.push(path); Some(cwd) } + pub fn get_path(&self) -> Option { + self.path.clone() + } } fn get_mime_type<'a>(extension: Option<&'a OsStr>) -> String { @@ -239,9 +242,9 @@ fn handle_connection(mut stream: TcpStream) { } Err(e) => match e.kind() { - io::ErrorKind::NotFound => format!("HTTP/1.1 404\r\n\r\n{:?} not found", req.file().unwrap().to_str()), - io::ErrorKind::PermissionDenied => format!("HTTP/1.1 403\r\n\r\n{:?} not readable", req.file().unwrap().to_str()), - io::ErrorKind::FileTooLarge => format!("HTTP/1.1 413\r\n\r\n{:?} was too large", req.file().unwrap().to_str()), + io::ErrorKind::NotFound => format!("HTTP/1.1 404\r\n\r\n{:?} not found", req.get_path().unwrap()), + io::ErrorKind::PermissionDenied => format!("HTTP/1.1 403\r\n\r\n{:?} not readable", req.get_path().unwrap()), + io::ErrorKind::FileTooLarge => format!("HTTP/1.1 413\r\n\r\n{:?} was too large", req.get_path().unwrap()), _ => format!("HTTP/1.1 500{0}{0}{e}", CLRF), }