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

Started on working with Multipart data in multipart forms

parent f85cfb4d
No related branches found
No related tags found
1 merge request!1Initial feature merge
...@@ -14,7 +14,7 @@ static MAX_HTTPMESSAGE_SIZE: u16 = 4196; ...@@ -14,7 +14,7 @@ static MAX_HTTPMESSAGE_SIZE: u16 = 4196;
pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoint<'_>>) { pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoint<'_>>) {
let mut buf_reader = BufReader::new(&mut stream); let mut buf_reader = BufReader::new(&mut stream);
let mut http_request: Vec<String> = Vec::with_capacity(30); let mut http_request: Vec<String> = Vec::with_capacity(10);
loop { loop {
let mut buffer = String::new(); let mut buffer = String::new();
if let Err(_) = buf_reader.read_line(&mut buffer).await { if let Err(_) = buf_reader.read_line(&mut buffer).await {
...@@ -27,8 +27,6 @@ pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoin ...@@ -27,8 +27,6 @@ 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
} else { } else {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
use std::{collections::HashMap, error::Error, fmt::Display}; use std::{collections::HashMap, error::Error, fmt::Display};
use tokio::io::BufReader;
use crate::utils::mime::mime_enum::Mime; use crate::utils::mime::mime_enum::Mime;
static TWO_NEWLINES: u8 = 3; static TWO_NEWLINES: u8 = 3;
...@@ -211,7 +213,16 @@ impl Request<'_> { ...@@ -211,7 +213,16 @@ impl Request<'_> {
}; };
Ok(keymap) Ok(keymap)
} }
fn get_multipart( fn decode_multipart<'a>(
data: &Data,
keys: &[&'a str],
) -> HashMap<String, Result<Vec<u8>, ParseFormError>> {
let mut data = data.buffer.as_ref();
let mut buf_reader = BufReader::new(&mut data);
let mut http_request: Vec<String> = Vec::with_capacity(2);
todo!()
}
fn get_multipart_data(
data: &[u8], data: &[u8],
boundary: &[u8], boundary: &[u8],
end_boundary: &[u8], end_boundary: &[u8],
......
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