@@ -3,6 +3,7 @@ use std::future::Future;
33use std:: pin:: Pin ;
44use log:: trace;
55use tokio:: io:: { AsyncBufReadExt , AsyncReadExt , AsyncWriteExt , BufReader , BufWriter } ;
6+ use case_insensitive_hashmap:: CaseInsensitiveHashMap as CIHashMap ;
67use crate :: config:: GARBAGE_DATA ;
78use crate :: http:: { Method , MethodStr } ;
89use crate :: http:: response:: Response ;
@@ -13,7 +14,7 @@ pub struct Request {
1314 pub method : Method ,
1415 pub remote_addr : String ,
1516 pub query_params : HashMap < String , String > ,
16- pub headers : HashMap < String , String > ,
17+ pub headers : CIHashMap < String > ,
1718 pub form_data : HashMap < String , String >
1819}
1920
@@ -189,11 +190,11 @@ fn hex_string_to_int(hex_string: &str) -> Option<u64> {
189190 }
190191}
191192
192- pub async fn header_parser < R > ( buf_reader : & mut BufReader < R > ) -> HashMap < String , String >
193+ pub async fn header_parser < R > ( buf_reader : & mut BufReader < R > ) -> CIHashMap < String >
193194where
194195 R : AsyncReadExt + Unpin
195196{
196- let mut headers_out = HashMap :: new ( ) ;
197+ let mut headers_out = CIHashMap :: new ( ) ;
197198 ' header_loop: loop {
198199 if let Ok ( Some ( header_line) ) = buf_reader. lines ( ) . next_line ( ) . await {
199200 if header_line. is_empty ( ) {
@@ -211,7 +212,7 @@ where
211212 headers_out
212213}
213214
214- fn check_has_body ( headers : & HashMap < String , String > ) -> ( Option < BodyType > , Option < u64 > ) {
215+ fn check_has_body ( headers : & CIHashMap < String > ) -> ( Option < BodyType > , Option < u64 > ) {
215216 let content_type_form = if let Some ( content_type) = headers. get ( "Content-Type" ) {
216217 if content_type. starts_with ( "multipart/form-data;" ) {
217218 Some ( BodyType :: Form )
@@ -279,7 +280,7 @@ fn clear_path_end_slash(input: &str) -> &str {
279280 }
280281}
281282
282- fn trust_addr_proxy ( headers : & HashMap < String , String > , remote_addr : & str ) -> String {
283+ fn trust_addr_proxy ( headers : & CIHashMap < String > , remote_addr : & str ) -> String {
283284 if let Some ( remote_ip) = headers. get ( "X-Real-IP" ) {
284285 remote_ip. to_string ( )
285286 } else {
0 commit comments