diff --git a/src-tauri/src/errors.rs b/src-tauri/src/errors.rs index 3280e1e..05d9776 100644 --- a/src-tauri/src/errors.rs +++ b/src-tauri/src/errors.rs @@ -121,7 +121,8 @@ pub enum RequestError { StreamIOError(#[from] std::io::Error), // #[error("Received invalid UTF-8 in request")] // InvalidUtf8, - // MalformedHttpRequest, + #[error("HTTP request malformed")] + BadRequest, #[error("HTTP request too large")] RequestTooLarge, #[error("Error accessing credentials: {0}")] diff --git a/src-tauri/src/server.rs b/src-tauri/src/server.rs index ee06012..15ccfd6 100644 --- a/src-tauri/src/server.rs +++ b/src-tauri/src/server.rs @@ -103,6 +103,11 @@ impl Handler { println!("{}", std::str::from_utf8(&buf).unwrap()); } + let path = buf.split(|&c| &[c] == b" ") + .skip(1) + .next() + .ok_or(RequestError::BadRequest(buf))?; + Ok(buf) }