diff --git a/src/main.rs b/src/main.rs index 7ff2561..e1fef7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ use std::{ }; use crate::{ - request::ServerPath, + request::Connection, response::{Response, ResponseCode, ResponseHeader}, shared_enums::{Content, ContentType}, }; @@ -30,12 +30,12 @@ fn main() -> std::io::Result<()> { println!("{req:?}"); let response = match req.path.path.to_string().as_str(){ - "css.css" => Response::new().with_code(ResponseCode::Ok).with_data(b"body{background-color: #000000;}".to_vec()).with_header(ResponseHeader::ContentType(Content::new(ContentType::Text(shared_enums::TextType::Css)))), + "css.css" => Response::new().with_code(ResponseCode::Ok).with_data(b"body{background-color: #ff0000;}".to_vec()).with_header(ResponseHeader::ContentType(Content::new(ContentType::Text(shared_enums::TextType::Css)))), _ => Response::new() .with_code(ResponseCode::Ok) .with_data(b"
Jou jou jou
".to_vec()) - .with_header(ResponseHeader::ContentType(Content::html_utf8())), + .with_header(ResponseHeader::ContentType(Content::html_utf8())).with_header(ResponseHeader::Connection(Connection::KeepAlive)), }; response.respond(&mut stream)?; @@ -45,6 +45,7 @@ fn main() -> std::io::Result<()> { if req.headers.contains(&request::RequestHeader::Connection( request::Connection::Close, )) { + println!("Connection closed"); break; } } diff --git a/src/request.rs b/src/request.rs index 43bcabb..a08301d 100644 --- a/src/request.rs +++ b/src/request.rs @@ -38,6 +38,17 @@ pub enum Connection { Other(Box