diff --git a/src/client/connector.rs b/src/client/connector.rs index 3bcc57c72..1ff0efe51 100644 --- a/src/client/connector.rs +++ b/src/client/connector.rs @@ -1007,22 +1007,22 @@ impl Protocol { } } - fn is_http(&self) -> bool { - match *self { + fn is_http(self) -> bool { + match self { Protocol::Https | Protocol::Http => true, _ => false, } } - fn is_secure(&self) -> bool { - match *self { + fn is_secure(self) -> bool { + match self { Protocol::Https | Protocol::Wss => true, _ => false, } } - fn port(&self) -> u16 { - match *self { + fn port(self) -> u16 { + match self { Protocol::Http | Protocol::Ws => 80, Protocol::Https | Protocol::Wss => 443, } diff --git a/src/header/mod.rs b/src/header/mod.rs index 847cb53bf..291bc6eac 100644 --- a/src/header/mod.rs +++ b/src/header/mod.rs @@ -129,8 +129,8 @@ pub enum ContentEncoding { impl ContentEncoding { #[inline] /// Is the content compressed? - pub fn is_compression(&self) -> bool { - match *self { + pub fn is_compression(self) -> bool { + match self { ContentEncoding::Identity | ContentEncoding::Auto => false, _ => true, } @@ -138,8 +138,8 @@ impl ContentEncoding { #[inline] /// Convert content encoding to string - pub fn as_str(&self) -> &'static str { - match *self { + pub fn as_str(self) -> &'static str { + match self { #[cfg(feature = "brotli")] ContentEncoding::Br => "br", #[cfg(feature = "flate2")] @@ -152,8 +152,8 @@ impl ContentEncoding { #[inline] /// default quality value - pub fn quality(&self) -> f64 { - match *self { + pub fn quality(self) -> f64 { + match self { #[cfg(feature = "brotli")] ContentEncoding::Br => 1.1, #[cfg(feature = "flate2")] diff --git a/src/server/h1decoder.rs b/src/server/h1decoder.rs index 977e89a8e..d1948a0d1 100644 --- a/src/server/h1decoder.rs +++ b/src/server/h1decoder.rs @@ -130,7 +130,6 @@ impl H1Decoder { if let Ok(name) = HeaderName::from_bytes(&slice[idx.name.0..idx.name.1]) { - has_upgrade = has_upgrade || name == header::UPGRADE; // Unsafe: httparse check header value for valid utf-8 let value = unsafe { HeaderValue::from_shared_unchecked( @@ -176,6 +175,9 @@ impl H1Decoder { }; inner.flags.get_mut().set(MessageFlags::KEEPALIVE, ka); } + header::UPGRADE => { + has_upgrade = true; + } _ => (), } diff --git a/src/server/h1writer.rs b/src/server/h1writer.rs index d25f236d6..d8ef41517 100644 --- a/src/server/h1writer.rs +++ b/src/server/h1writer.rs @@ -204,9 +204,12 @@ impl Writer for H1Writer { ResponseLength::None => (), _ => continue, }, + DATE => { + has_date = true; + } _ => (), } - has_date = has_date || key == DATE; + let v = value.as_ref(); let k = key.as_str().as_bytes(); let len = k.len() + v.len() + 4;