0.35.4
This commit is contained in:
1 parent
cd3c28d390
commit
ff42a13dbf
3 files changed
+28
-30
No files matched your search
+3
-4
@@ -461,9 +461,7 @@ impl ServerHeader {
|
||||
}
|
||||
}
|
||||
}
|
||||
/// Returns a reusable `HeaderValue` for a configured, already validated header
|
||||
/// string. Values are parsed once per worker thread and then cloned (a reference
|
||||
/// count bump) instead of being re-validated and re-allocated on every response.
|
||||
|
||||
pub(crate) fn cached_header_value(value: &str) -> Option<HeaderValue> {
|
||||
const CAPACITY: usize = 16;
|
||||
thread_local! {
|
||||
@@ -475,7 +473,8 @@ pub(crate) fn cached_header_value(value: &str) -> Option<HeaderValue> {
|
||||
if let Some((_, header)) = cache.iter().find(|(key, _)| key.as_ref() == value) {
|
||||
return Some(header.clone());
|
||||
}
|
||||
let header = HeaderValue::from_maybe_shared(bytes::Bytes::copy_from_slice(value.as_bytes())).ok()?;
|
||||
let header =
|
||||
HeaderValue::from_maybe_shared(bytes::Bytes::copy_from_slice(value.as_bytes())).ok()?;
|
||||
if cache.len() >= CAPACITY {
|
||||
cache.remove(0);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user