server: rest: collapse nested if for less indentation

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2021-04-07 17:57:19 +02:00
parent b84e8aaee9
commit c47609fedb

View File

@ -635,27 +635,21 @@ async fn handle_static_file_download(
} }
fn extract_lang_header(headers: &http::HeaderMap) -> Option<String> { fn extract_lang_header(headers: &http::HeaderMap) -> Option<String> {
if let Some(raw_cookie) = headers.get("COOKIE") { if let Some(Ok(cookie)) = headers.get("COOKIE").map(|v| v.to_str()) {
if let Ok(cookie) = raw_cookie.to_str() { return tools::extract_cookie(cookie, "PBSLangCookie");
return tools::extract_cookie(cookie, "PBSLangCookie");
}
} }
None None
} }
// FIXME: support handling multiple compression methods // FIXME: support handling multiple compression methods
fn extract_compression_method(headers: &http::HeaderMap) -> Option<CompressionMethod> { fn extract_compression_method(headers: &http::HeaderMap) -> Option<CompressionMethod> {
if let Some(raw_encoding) = headers.get(header::ACCEPT_ENCODING) { if let Some(Ok(encodings)) = headers.get(header::ACCEPT_ENCODING).map(|v| v.to_str()) {
if let Ok(encoding) = raw_encoding.to_str() { for encoding in encodings.split(&[',', ' '][..]) {
for encoding in encoding.split(&[',', ' '][..]) { if let Ok(method) = encoding.parse() {
if let Ok(method) = encoding.parse() { return Some(method);
return Some(method);
}
} }
} }
} }
None None
} }