From 291d2a88d04d83991b40948e08c5d1f5ab79a223 Mon Sep 17 00:00:00 2001 From: MeexReay Date: Fri, 13 Sep 2024 18:50:04 +0300 Subject: [PATCH] headers reference self eefefff --- Cargo.toml | 2 +- src/ezhttp/handler.rs | 8 ++++---- src/ezhttp/headers.rs | 20 ++++++++++---------- src/ezhttp/mod.rs | 1 - 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4983e82..3449a4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,4 +19,4 @@ threadpool = "1.8.1" lazy_static = "1.5.0" [features] -http_rrs = [] +flowgate = [] diff --git a/src/ezhttp/handler.rs b/src/ezhttp/handler.rs index 8f8ac30..fc71119 100644 --- a/src/ezhttp/handler.rs +++ b/src/ezhttp/handler.rs @@ -4,7 +4,7 @@ use std::{future::Future, pin::Pin, sync::Arc}; use tokio::net::TcpStream; use tokio_io_timeout::TimeoutStream; -#[cfg(feature = "http_rrs")] +#[cfg(feature = "flowgate")] use {super::read_line_lf, std::net::{ToSocketAddrs, SocketAddr}}; pub type Handler = Box, TimeoutStream) -> Pin + Send>> + Send + Sync>; @@ -49,9 +49,9 @@ macro_rules! pin_handler { }; } -#[cfg(feature = "http_rrs")] -/// HTTP_RRS handler -pub async fn handler_http_rrs( +#[cfg(feature = "flowgate")] +/// Flowgate handler +pub async fn handler_flowgate( server: Arc, mut sock: Stream, ) { diff --git a/src/ezhttp/headers.rs b/src/ezhttp/headers.rs index 63cf0e0..405c4fc 100644 --- a/src/ezhttp/headers.rs +++ b/src/ezhttp/headers.rs @@ -37,8 +37,8 @@ impl Headers { } } - pub fn contains(self, header: impl ToString) -> bool { - for (k, _) in self.entries { + pub fn contains(&self, header: impl ToString) -> bool { + for (k, _) in &self.entries { if k.to_lowercase() == header.to_string().to_lowercase() { return true; } @@ -46,10 +46,10 @@ impl Headers { return false; } - pub fn get(self, key: impl ToString) -> Option { - for (k, v) in self.entries { + pub fn get(&self, key: impl ToString) -> Option { + for (k, v) in &self.entries { if k.to_lowercase() == key.to_string().to_lowercase() { - return Some(v); + return Some(v.clone()); } } return None; @@ -74,19 +74,19 @@ impl Headers { } } - pub fn keys(self) -> Vec { + pub fn keys(&self) -> Vec { self.entries.iter().map(|e| e.0.clone()).collect() } - pub fn values(self) -> Vec { + pub fn values(&self) -> Vec { self.entries.iter().map(|e| e.1.clone()).collect() } - pub fn entries(self) -> Vec<(String, String)> { - return self.entries; + pub fn entries(&self) -> Vec<(String, String)> { + return self.entries.clone(); } - pub fn len(self) -> usize { + pub fn len(&self) -> usize { return self.entries.len(); } diff --git a/src/ezhttp/mod.rs b/src/ezhttp/mod.rs index 595e001..3d55a17 100644 --- a/src/ezhttp/mod.rs +++ b/src/ezhttp/mod.rs @@ -51,7 +51,6 @@ async fn read_line_crlf(data: &mut (impl AsyncReadExt + Unpin)) -> Result Result { match read_line(data).await { Ok(i) => Ok(i[..i.len() - 1].to_string()),