From 6744b6dee14a559238a0ba7944c391a5edc14f07 Mon Sep 17 00:00:00 2001 From: Compositr Date: Fri, 1 Nov 2024 21:15:34 +1100 Subject: [PATCH] refactor: dry'd HTTP/1.1 --- src/http/responses.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/http/responses.rs b/src/http/responses.rs index 3a06be4..553c5bc 100644 --- a/src/http/responses.rs +++ b/src/http/responses.rs @@ -24,15 +24,15 @@ pub type UnitOrBoxedError = Result<(), Box>; fn send_response(mut stream: TcpStream, status: u16, body: &str) -> UnitOrBoxedError { let status_line = match status { - 200 => "HTTP/1.1 200 OK", - 400 => "HTTP/1.1 400 BAD REQUEST", - 404 => "HTTP/1.1 404 NOT FOUND", - 405 => "HTTP/1.1 405 METHOD NOT ALLOWED", - _ => "HTTP/1.1 500 INTERNAL SERVER ERROR", + 200 => "200 OK", + 400 => "400 BAD REQUEST", + 404 => "404 NOT FOUND", + 405 => "405 METHOD NOT ALLOWED", + _ => "500 INTERNAL SERVER ERROR", }; let response = format!( - "{}\r\nContent-Length: {}\r\nServer: luciders/0.1.0\r\n\r\n{}", + "{}\r\nContent-Length: {}\r\nServer: luciders/0.1.0\r\n\r\nHTTP/1.1 {}", status_line, body.len(), body