From f352c98e93b99c812a745365fa41c9930c77e28e Mon Sep 17 00:00:00 2001 From: MeexReay Date: Sun, 1 Dec 2024 02:22:32 +0300 Subject: [PATCH] body update and refactor --- examples/simple_site.rs | 4 ++-- examples/small_site.rs | 4 ++-- src/ezhttp/body.rs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/simple_site.rs b/examples/simple_site.rs index f0f9f00..faa7af7 100644 --- a/examples/simple_site.rs +++ b/examples/simple_site.rs @@ -11,7 +11,7 @@ use ezhttp::{ server::{ starter::HttpServerStarter, HttpServer - } + }, Sendable }; struct EzSite { @@ -63,7 +63,7 @@ impl EzSite { } impl HttpServer for EzSite { - async fn on_request(&self, req: &HttpRequest) -> Option { + async fn on_request(&self, req: &HttpRequest) -> Option { println!("{} > {} {}", req.addr, req.method, req.url.to_path_string()); if let Some(resp) = self.get_main_page(req).await { diff --git a/examples/small_site.rs b/examples/small_site.rs index 3512152..e9b2793 100644 --- a/examples/small_site.rs +++ b/examples/small_site.rs @@ -1,9 +1,9 @@ -use ezhttp::prelude::*; +use ezhttp::{prelude::*, Sendable}; struct EzSite(String); impl HttpServer for EzSite { - async fn on_request(&self, req: &HttpRequest) -> Option { + async fn on_request(&self, req: &HttpRequest) -> Option { println!("{} > {} {}", req.addr, req.method, req.url.to_path_string()); if req.url.path == "/" { diff --git a/src/ezhttp/body.rs b/src/ezhttp/body.rs index bed0569..10c7382 100644 --- a/src/ezhttp/body.rs +++ b/src/ezhttp/body.rs @@ -110,10 +110,10 @@ impl Body { Some((name.to_lowercase(), value.to_string())) }).collect::>(); let content_type = head.iter() - .find(|o| o.0 == "content-type") + .find(|o| o.0.to_lowercase() == "content-type") .map(|o| o.1.clone()); let (name, filename) = head.iter() - .find(|o| o.0 == "content-disposition") + .find(|o| o.0.to_lowercase() == "content-disposition") .map(|o| o.1.split(";").filter(|o| o == &"form-data").map(|s| s.trim().to_string()).collect::>()) .map(|o| ( o.iter().find(|k| k.starts_with("name=\"")).map(|k| k[6..k.len()-1].to_string()),