diff --git a/rpxy-lib/Cargo.toml b/rpxy-lib/Cargo.toml index bd0e219..89c4868 100644 --- a/rpxy-lib/Cargo.toml +++ b/rpxy-lib/Cargo.toml @@ -64,9 +64,7 @@ hyper-tls = { version = "0.6.0", features = [ "alpn", "vendored", ], optional = true } -# TODO: Work around to enable rustls-platform-verifier feature: https://github.com/rustls/hyper-rustls/pull/276 -# hyper-rustls = { version = "0.27.2", default-features = false, features = [ -hyper-rustls = { git = "https://github.com/junkurihara/hyper-rustls", branch = "main", features = [ +hyper-rustls = { version = "0.27.3", default-features = false, features = [ "aws-lc-rs", "http1", "http2", diff --git a/rpxy-lib/src/message_handler/utils_headers.rs b/rpxy-lib/src/message_handler/utils_headers.rs index 9be45e5..d058f88 100644 --- a/rpxy-lib/src/message_handler/utils_headers.rs +++ b/rpxy-lib/src/message_handler/utils_headers.rs @@ -30,16 +30,12 @@ pub(super) fn takeout_sticky_cookie_lb_context( let cookies_iter = entry .iter() .flat_map(|v| v.to_str().unwrap_or("").split(';').map(|v| v.trim())); - let (sticky_cookies, without_sticky_cookies): (Vec<_>, Vec<_>) = cookies_iter - .into_iter() - .partition(|v| v.starts_with(expected_cookie_name)); + let (sticky_cookies, without_sticky_cookies): (Vec<_>, Vec<_>) = + cookies_iter.into_iter().partition(|v| v.starts_with(expected_cookie_name)); if sticky_cookies.is_empty() { return Ok(None); } - ensure!( - sticky_cookies.len() == 1, - "Invalid cookie: Multiple sticky cookie values" - ); + ensure!(sticky_cookies.len() == 1, "Invalid cookie: Multiple sticky cookie values"); let cookies_passed_to_upstream = without_sticky_cookies.join("; "); let cookie_passed_to_lb = sticky_cookies.first().unwrap(); @@ -59,10 +55,7 @@ pub(super) fn takeout_sticky_cookie_lb_context( /// Set-Cookie if LB Sticky is enabled and if cookie is newly created/updated. /// Set-Cookie response header could be in multiple lines. /// https://developer.mozilla.org/ja/docs/Web/HTTP/Headers/Set-Cookie -pub(super) fn set_sticky_cookie_lb_context( - headers: &mut HeaderMap, - context_from_lb: &LoadBalanceContext, -) -> Result<()> { +pub(super) fn set_sticky_cookie_lb_context(headers: &mut HeaderMap, context_from_lb: &LoadBalanceContext) -> Result<()> { let sticky_cookie_string: String = context_from_lb.sticky_cookie.clone().try_into()?; let new_header_val: HeaderValue = sticky_cookie_string.parse()?; let expected_cookie_name = &context_from_lb.sticky_cookie.value.name; @@ -122,7 +115,7 @@ pub(super) fn apply_upstream_options_to_header( // add upgrade-insecure-requests in request header if not exist headers .entry(header::UPGRADE_INSECURE_REQUESTS) - .or_insert(HeaderValue::from_bytes(&[b'1']).unwrap()); + .or_insert(HeaderValue::from_bytes(b"1").unwrap()); } _ => (), } @@ -141,7 +134,7 @@ pub(super) fn append_header_entry_with_comma(headers: &mut HeaderMap, key: &str, // entry.append(value.parse::()?); let mut new_value = Vec::::with_capacity(entry.get().as_bytes().len() + 2 + value.len()); new_value.put_slice(entry.get().as_bytes()); - new_value.put_slice(&[b',', b' ']); + new_value.put_slice(b", "); new_value.put_slice(value.as_bytes()); entry.insert(HeaderValue::from_bytes(&new_value)?); } diff --git a/rpxy-lib/src/message_handler/utils_request.rs b/rpxy-lib/src/message_handler/utils_request.rs index 8939433..b60835f 100644 --- a/rpxy-lib/src/message_handler/utils_request.rs +++ b/rpxy-lib/src/message_handler/utils_request.rs @@ -16,7 +16,7 @@ impl InspectParseHost for Request { /// Inspect and extract hostname from either the request HOST header or request line fn inspect_parse_host(&self) -> Result> { let drop_port = |v: &[u8]| { - if v.starts_with(&[b'[']) { + if v.starts_with(b"[") { // v6 address with bracket case. if port is specified, always it is in this case. let mut iter = v.split(|ptr| ptr == &b'[' || ptr == &b']'); iter.next().ok_or(anyhow!("Invalid Host header"))?; // first item is always blank