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) }