0.35.4
This commit is contained in:
1 parent
cd3c28d390
commit
ff42a13dbf
3 files changed
+28
-30
No files matched your search
Vendored
+2
-3
@@ -334,7 +334,8 @@ impl Settings {
|
||||
if transformed {
|
||||
value.push_str("; transformed");
|
||||
}
|
||||
headers.append(::http::header::CACHE_STATUS,
|
||||
headers.append(
|
||||
::http::header::CACHE_STATUS,
|
||||
HeaderValue::from_maybe_shared(bytes::Bytes::from(value))
|
||||
.expect("generated Cache-Status member"),
|
||||
);
|
||||
@@ -360,8 +361,6 @@ fn insert_cache_diagnostic(
|
||||
value: HeaderValue,
|
||||
) {
|
||||
let name = http::HeaderName::from_static(name);
|
||||
// Fast path: the origin did not send this diagnostic, so there is nothing to
|
||||
// preserve under the X-Upstream-* alias and no temporary vector is needed.
|
||||
if headers.contains_key(&name) {
|
||||
let upstream_values: Vec<HeaderValue> = headers.get_all(&name).iter().cloned().collect();
|
||||
let upstream_name = http::HeaderName::from_static(upstream_name);
|
||||
|
||||
+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