From fd86d73a0391a08d707aebc63074e2d88d83f330 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 18 Mar 2019 05:26:12 -0700 Subject: [PATCH] fix response upgrade type --- src/message.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/message.rs b/src/message.rs index bf465ee6d..4e46093f6 100644 --- a/src/message.rs +++ b/src/message.rs @@ -106,6 +106,18 @@ impl Head for RequestHead { } } + fn upgrade(&self) -> bool { + if let Some(hdr) = self.headers().get(header::CONNECTION) { + if let Ok(s) = hdr.to_str() { + s.to_ascii_lowercase().contains("upgrade") + } else { + false + } + } else { + false + } + } + fn pool() -> &'static MessagePool { REQUEST_POOL.with(|p| *p) } @@ -194,6 +206,10 @@ impl Head for ResponseHead { } } + fn upgrade(&self) -> bool { + self.connection_type() == ConnectionType::Upgrade + } + fn pool() -> &'static MessagePool { RESPONSE_POOL.with(|p| *p) }