}
fn extract_lang_header(headers: &http::HeaderMap) -> Option<String> {
- 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<CompressionMethod> {
- 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
}