Skip to content
Snippets Groups Projects
Commit 31f29ad0 authored by codecraft's avatar codecraft :crocodile:
Browse files

Start working on cookies

parent 94944f32
No related branches found
No related tags found
1 merge request!1Initial feature merge
......@@ -26,6 +26,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
}
http_request.push(buffer);
}
println!("{:?}", http_request);
let request_status_line = if let Some(status_line) = http_request.get(0).cloned() {
status_line
......@@ -33,6 +34,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
eprintln!("\x1b[31mAborting due to missing headers\x1b[0m");
return;
};
let request = Request {
uri: if let Some(uri) = &request_status_line.split(" ").nth(1) {
*uri
......@@ -40,6 +42,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
eprintln!("\x1b[31mAborting due to invalid status line\x1b[0m");
return;
},
cookies: None,
headers: http_request,
method: if let Some(method) = request_status_line
.split(" ")
......@@ -53,7 +56,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
} else {
eprintln!("\x1b[31mAborting due to invalid status line\x1b[0m");
return;
}
},
};
let mut data = Data {
......
......@@ -37,6 +37,7 @@ pub struct Request<'a> {
pub uri: Uri<'a>,
pub headers: HeaderMap,
pub method: Method,
pub cookies: Option<Vec<&'a str>>,
// pub connection: ConnectionMeta,
}
......@@ -316,6 +317,7 @@ mod test {
uri: "",
headers: vec!["Content-Type: application/x-www-form-urlencoded".to_string()],
method: crate::handling::methods::Method::Post,
cookies: None,
};
let data = Data {
buffer: b"message=23&message1=24".to_vec(),
......@@ -334,6 +336,7 @@ mod test {
uri: "",
headers: vec!["Content-Type: multipart/form-data; boundary=\"boundary\"".to_string()],
method: crate::handling::methods::Method::Post,
cookies: None,
};
let data = Data {
buffer: b"--boundary\r
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment