From: Thomas Lamprecht Date: Wed, 7 Apr 2021 15:57:19 +0000 (+0200) Subject: server: rest: collapse nested if for less indentation X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1b2a34166d7f4098a48dbbc1c9968815bb52099d;p=proxmox.git server: rest: collapse nested if for less indentation Signed-off-by: Thomas Lamprecht --- diff --git a/src/server/rest.rs b/src/server/rest.rs index 7922897c..13d379c7 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -635,27 +635,21 @@ async fn handle_static_file_download( } fn extract_lang_header(headers: &http::HeaderMap) -> Option { - if let Some(raw_cookie) = headers.get("COOKIE") { - if let Ok(cookie) = raw_cookie.to_str() { - return tools::extract_cookie(cookie, "PBSLangCookie"); - } + if let Some(Ok(cookie)) = headers.get("COOKIE").map(|v| v.to_str()) { + return tools::extract_cookie(cookie, "PBSLangCookie"); } - None } // FIXME: support handling multiple compression methods fn extract_compression_method(headers: &http::HeaderMap) -> Option { - if let Some(raw_encoding) = headers.get(header::ACCEPT_ENCODING) { - if let Ok(encoding) = raw_encoding.to_str() { - for encoding in encoding.split(&[',', ' '][..]) { - if let Ok(method) = encoding.parse() { - return Some(method); - } + if let Some(Ok(encodings)) = headers.get(header::ACCEPT_ENCODING).map(|v| v.to_str()) { + for encoding in encodings.split(&[',', ' '][..]) { + if let Ok(method) = encoding.parse() { + return Some(method); } } } - None }