From da34d469cfe6cafeb9b1b1fc05fa429f88c890b9 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Fri, 15 Apr 2016 18:14:16 -0400 Subject: [PATCH] Cleanup retrieval of last slice item. --- components/net/resource_thread.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/components/net/resource_thread.rs b/components/net/resource_thread.rs index c218c793ebb..38ad17e9a00 100644 --- a/components/net/resource_thread.rs +++ b/components/net/resource_thread.rs @@ -83,11 +83,8 @@ pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadat let mut check_for_apache_bug = ApacheBugFlag::OFF; if let Some(ref headers) = metadata.headers { - if let Some(ref raw_content_type) = headers.get_raw("content-type") { - if raw_content_type.len() > 0 { - let last_raw_content_type = &raw_content_type[raw_content_type.len() - 1]; - check_for_apache_bug = ApacheBugFlag::from_content_type(last_raw_content_type) - } + if let Some(ref content_type) = headers.get_raw("content-type").and_then(|c| c.last()) { + check_for_apache_bug = ApacheBugFlag::from_content_type(content_type) } if let Some(ref raw_content_type_options) = headers.get_raw("X-content-type-options") { if raw_content_type_options.iter().any(|ref opt| *opt == b"nosniff") {