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 ...@@ -26,6 +26,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
} }
http_request.push(buffer); http_request.push(buffer);
} }
println!("{:?}", http_request);
let request_status_line = if let Some(status_line) = http_request.get(0).cloned() { let request_status_line = if let Some(status_line) = http_request.get(0).cloned() {
status_line status_line
...@@ -33,6 +34,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin ...@@ -33,6 +34,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
eprintln!("\x1b[31mAborting due to missing headers\x1b[0m"); eprintln!("\x1b[31mAborting due to missing headers\x1b[0m");
return; return;
}; };
let request = Request { let request = Request {
uri: if let Some(uri) = &request_status_line.split(" ").nth(1) { uri: if let Some(uri) = &request_status_line.split(" ").nth(1) {
*uri *uri
...@@ -40,6 +42,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin ...@@ -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"); eprintln!("\x1b[31mAborting due to invalid status line\x1b[0m");
return; return;
}, },
cookies: None,
headers: http_request, headers: http_request,
method: if let Some(method) = request_status_line method: if let Some(method) = request_status_line
.split(" ") .split(" ")
...@@ -53,7 +56,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin ...@@ -53,7 +56,7 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin
} else { } else {
eprintln!("\x1b[31mAborting due to invalid status line\x1b[0m"); eprintln!("\x1b[31mAborting due to invalid status line\x1b[0m");
return; return;
} },
}; };
let mut data = Data { let mut data = Data {
......
...@@ -37,6 +37,7 @@ pub struct Request<'a> { ...@@ -37,6 +37,7 @@ pub struct Request<'a> {
pub uri: Uri<'a>, pub uri: Uri<'a>,
pub headers: HeaderMap, pub headers: HeaderMap,
pub method: Method, pub method: Method,
pub cookies: Option<Vec<&'a str>>,
// pub connection: ConnectionMeta, // pub connection: ConnectionMeta,
} }
...@@ -316,6 +317,7 @@ mod test { ...@@ -316,6 +317,7 @@ mod test {
uri: "", uri: "",
headers: vec!["Content-Type: application/x-www-form-urlencoded".to_string()], headers: vec!["Content-Type: application/x-www-form-urlencoded".to_string()],
method: crate::handling::methods::Method::Post, method: crate::handling::methods::Method::Post,
cookies: None,
}; };
let data = Data { let data = Data {
buffer: b"message=23&message1=24".to_vec(), buffer: b"message=23&message1=24".to_vec(),
...@@ -334,6 +336,7 @@ mod test { ...@@ -334,6 +336,7 @@ mod test {
uri: "", uri: "",
headers: vec!["Content-Type: multipart/form-data; boundary=\"boundary\"".to_string()], headers: vec!["Content-Type: multipart/form-data; boundary=\"boundary\"".to_string()],
method: crate::handling::methods::Method::Post, method: crate::handling::methods::Method::Post,
cookies: None,
}; };
let data = Data { let data = Data {
buffer: b"--boundary\r 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