M src/error.rs => src/error.rs +3 -0
@@ 17,6 17,9 @@ pub enum TaurusError {
#[error("invalid request: {0}")]
InvalidRequest(String),
+ #[error("invalid Unicode character in the input")]
+ InvalidUnicode(#[from] std::string::FromUtf8Error),
+
#[error("failed to bind: {0}")]
BindFailed(io::Error),
M src/main.rs => src/main.rs +1 -1
@@ 99,7 99,7 @@ fn handle_client(mut stream: TlsStream<TcpStream>, static_root: &str) -> TaurusR
.read(&mut buffer)
.map_err(TaurusError::StreamReadFailed)?;
- let raw_request = String::from_utf8_lossy(&buffer[..]).into_owned();
+ let raw_request = String::from_utf8(buffer.to_vec())?;
let request = GeminiRequest::parse(&raw_request)?;
let url_path = request.file_path();