From f29d3004ef1279097b0f55bef27fe95daf940425 Mon Sep 17 00:00:00 2001 From: Darius Auding <Darius.auding@gmx.de> Date: Fri, 16 Jun 2023 18:51:51 +0200 Subject: [PATCH] Started on working with Multipart data in multipart forms --- core/http/src/handlers/handlers.rs | 4 +--- core/http/src/handling/request.rs | 13 ++++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/http/src/handlers/handlers.rs b/core/http/src/handlers/handlers.rs index 4459968..0f724cd 100755 --- a/core/http/src/handlers/handlers.rs +++ b/core/http/src/handlers/handlers.rs @@ -14,7 +14,7 @@ static MAX_HTTPMESSAGE_SIZE: u16 = 4196; pub async fn handle_connection(mut stream: TcpStream, mountpoints: Vec<MountPoint<'_>>) { 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 { let mut buffer = String::new(); 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 http_request.push(buffer); } - // println!("{:#?}", http_request); - let request_status_line = if let Some(status_line) = http_request.get(0).cloned() { status_line } else { diff --git a/core/http/src/handling/request.rs b/core/http/src/handling/request.rs index ff7e338..ff4db83 100644 --- a/core/http/src/handling/request.rs +++ b/core/http/src/handling/request.rs @@ -2,6 +2,8 @@ use std::{collections::HashMap, error::Error, fmt::Display}; +use tokio::io::BufReader; + use crate::utils::mime::mime_enum::Mime; static TWO_NEWLINES: u8 = 3; @@ -211,7 +213,16 @@ impl Request<'_> { }; 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], boundary: &[u8], end_boundary: &[u8], -- GitLab