mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
perf(http): avoid clone getting request method and url (#26250)
This commit is contained in:
parent
4c9eee3ebe
commit
7f3747f2ef
3 changed files with 15 additions and 16 deletions
|
@ -119,7 +119,7 @@ fn encodings_iter_inner<'s>(
|
||||||
};
|
};
|
||||||
Some(Ok((encoding, qval)))
|
Some(Ok((encoding, qval)))
|
||||||
})
|
})
|
||||||
.map(|r| r?) // flatten Result<Result<...
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -296,7 +296,7 @@ where
|
||||||
let authority: v8::Local<v8::Value> = match request_properties.authority {
|
let authority: v8::Local<v8::Value> = match request_properties.authority {
|
||||||
Some(authority) => v8::String::new_from_utf8(
|
Some(authority) => v8::String::new_from_utf8(
|
||||||
scope,
|
scope,
|
||||||
authority.as_ref(),
|
authority.as_bytes(),
|
||||||
v8::NewStringType::Normal,
|
v8::NewStringType::Normal,
|
||||||
)
|
)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
|
|
@ -34,8 +34,8 @@ pub struct HttpConnectionProperties {
|
||||||
pub stream_type: NetworkStreamType,
|
pub stream_type: NetworkStreamType,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HttpRequestProperties {
|
pub struct HttpRequestProperties<'a> {
|
||||||
pub authority: Option<String>,
|
pub authority: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pluggable trait to determine listen, connection and request properties
|
/// Pluggable trait to determine listen, connection and request properties
|
||||||
|
@ -84,11 +84,11 @@ pub trait HttpPropertyExtractor {
|
||||||
) -> NetworkStream;
|
) -> NetworkStream;
|
||||||
|
|
||||||
/// Determines the request properties.
|
/// Determines the request properties.
|
||||||
fn request_properties(
|
fn request_properties<'a>(
|
||||||
connection_properties: &HttpConnectionProperties,
|
connection_properties: &'a HttpConnectionProperties,
|
||||||
uri: &Uri,
|
uri: &'a Uri,
|
||||||
headers: &HeaderMap,
|
headers: &'a HeaderMap,
|
||||||
) -> HttpRequestProperties;
|
) -> HttpRequestProperties<'a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DefaultHttpPropertyExtractor {}
|
pub struct DefaultHttpPropertyExtractor {}
|
||||||
|
@ -180,18 +180,17 @@ impl HttpPropertyExtractor for DefaultHttpPropertyExtractor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn request_properties(
|
fn request_properties<'a>(
|
||||||
connection_properties: &HttpConnectionProperties,
|
connection_properties: &'a HttpConnectionProperties,
|
||||||
uri: &Uri,
|
uri: &'a Uri,
|
||||||
headers: &HeaderMap,
|
headers: &'a HeaderMap,
|
||||||
) -> HttpRequestProperties {
|
) -> HttpRequestProperties<'a> {
|
||||||
let authority = req_host(
|
let authority = req_host(
|
||||||
uri,
|
uri,
|
||||||
headers,
|
headers,
|
||||||
connection_properties.stream_type,
|
connection_properties.stream_type,
|
||||||
connection_properties.local_port.unwrap_or_default(),
|
connection_properties.local_port.unwrap_or_default(),
|
||||||
)
|
);
|
||||||
.map(|s| s.into_owned());
|
|
||||||
|
|
||||||
HttpRequestProperties { authority }
|
HttpRequestProperties { authority }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue