diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-10-14 23:25:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-14 23:25:47 -0400 |
commit | 7f3747f2ef7cc9e1d45aa33360afdfe62cd20c56 (patch) | |
tree | a5d6237b2c3fc1ec5ee664a8bbde4d00f7890ca8 /ext/http | |
parent | 4c9eee3ebe383f0aa8f082dd6831f609cd5d5abb (diff) |
perf(http): avoid clone getting request method and url (#26250)
Diffstat (limited to 'ext/http')
-rw-r--r-- | ext/http/fly_accept_encoding.rs | 2 | ||||
-rw-r--r-- | ext/http/http_next.rs | 2 | ||||
-rw-r--r-- | ext/http/request_properties.rs | 27 |
3 files changed, 15 insertions, 16 deletions
diff --git a/ext/http/fly_accept_encoding.rs b/ext/http/fly_accept_encoding.rs index 94e336876..4d6fd2231 100644 --- a/ext/http/fly_accept_encoding.rs +++ b/ext/http/fly_accept_encoding.rs @@ -119,7 +119,7 @@ fn encodings_iter_inner<'s>( }; Some(Ok((encoding, qval))) }) - .map(|r| r?) // flatten Result<Result<... + .flatten() } #[cfg(test)] diff --git a/ext/http/http_next.rs b/ext/http/http_next.rs index efe1b88c9..a58c4be5c 100644 --- a/ext/http/http_next.rs +++ b/ext/http/http_next.rs @@ -296,7 +296,7 @@ where let authority: v8::Local<v8::Value> = match request_properties.authority { Some(authority) => v8::String::new_from_utf8( scope, - authority.as_ref(), + authority.as_bytes(), v8::NewStringType::Normal, ) .unwrap() diff --git a/ext/http/request_properties.rs b/ext/http/request_properties.rs index 1422c7417..39d35a79f 100644 --- a/ext/http/request_properties.rs +++ b/ext/http/request_properties.rs @@ -34,8 +34,8 @@ pub struct HttpConnectionProperties { pub stream_type: NetworkStreamType, } -pub struct HttpRequestProperties { - pub authority: Option<String>, +pub struct HttpRequestProperties<'a> { + pub authority: Option<Cow<'a, str>>, } /// Pluggable trait to determine listen, connection and request properties @@ -84,11 +84,11 @@ pub trait HttpPropertyExtractor { ) -> NetworkStream; /// Determines the request properties. - fn request_properties( - connection_properties: &HttpConnectionProperties, - uri: &Uri, - headers: &HeaderMap, - ) -> HttpRequestProperties; + fn request_properties<'a>( + connection_properties: &'a HttpConnectionProperties, + uri: &'a Uri, + headers: &'a HeaderMap, + ) -> HttpRequestProperties<'a>; } pub struct DefaultHttpPropertyExtractor {} @@ -180,18 +180,17 @@ impl HttpPropertyExtractor for DefaultHttpPropertyExtractor { } } - fn request_properties( - connection_properties: &HttpConnectionProperties, - uri: &Uri, - headers: &HeaderMap, - ) -> HttpRequestProperties { + fn request_properties<'a>( + connection_properties: &'a HttpConnectionProperties, + uri: &'a Uri, + headers: &'a HeaderMap, + ) -> HttpRequestProperties<'a> { let authority = req_host( uri, headers, connection_properties.stream_type, connection_properties.local_port.unwrap_or_default(), - ) - .map(|s| s.into_owned()); + ); HttpRequestProperties { authority } } |