From 53aa24b06ba6ad8c1844f8f109ff982b24784923 Mon Sep 17 00:00:00 2001 From: Alexey Galakhov Date: Fri, 17 Mar 2017 16:05:03 +0100 Subject: [PATCH] Fix warnings Signed-off-by: Alexey Galakhov --- src/handshake/client.rs | 4 ++-- src/handshake/headers.rs | 12 ++++++------ src/handshake/server.rs | 8 ++++---- src/protocol/mod.rs | 3 ++- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/handshake/client.rs b/src/handshake/client.rs index 4ea52e1..9beb5eb 100644 --- a/src/handshake/client.rs +++ b/src/handshake/client.rs @@ -207,8 +207,8 @@ mod tests { #[test] fn response_parsing() { - const data: &'static [u8] = b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; - let (_, resp) = Response::try_parse(data).unwrap().unwrap(); + const DATA: &'static [u8] = b"HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n"; + let (_, resp) = Response::try_parse(DATA).unwrap().unwrap(); assert_eq!(resp.code, 200); assert_eq!(resp.headers.find_first("Content-Type"), Some(&b"text/html"[..])); } diff --git a/src/handshake/headers.rs b/src/handshake/headers.rs index c765caf..260b578 100644 --- a/src/handshake/headers.rs +++ b/src/handshake/headers.rs @@ -101,12 +101,12 @@ mod tests { #[test] fn headers() { - const data: &'static [u8] = + const DATA: &'static [u8] = b"Host: foo.com\r\n\ Connection: Upgrade\r\n\ Upgrade: websocket\r\n\ \r\n"; - let (_, hdr) = Headers::try_parse(data).unwrap().unwrap(); + let (_, hdr) = Headers::try_parse(DATA).unwrap().unwrap(); assert_eq!(hdr.find_first("Host"), Some(&b"foo.com"[..])); assert_eq!(hdr.find_first("Upgrade"), Some(&b"websocket"[..])); assert_eq!(hdr.find_first("Connection"), Some(&b"Upgrade"[..])); @@ -118,14 +118,14 @@ mod tests { #[test] fn headers_iter() { - const data: &'static [u8] = + const DATA: &'static [u8] = b"Host: foo.com\r\n\ Sec-WebSocket-Extensions: permessage-deflate\r\n\ Connection: Upgrade\r\n\ Sec-WebSocket-ExtenSIONS: permessage-unknown\r\n\ Upgrade: websocket\r\n\ \r\n"; - let (_, hdr) = Headers::try_parse(data).unwrap().unwrap(); + let (_, hdr) = Headers::try_parse(DATA).unwrap().unwrap(); let mut iter = hdr.find("Sec-WebSocket-Extensions"); assert_eq!(iter.next(), Some(&b"permessage-deflate"[..])); assert_eq!(iter.next(), Some(&b"permessage-unknown"[..])); @@ -134,11 +134,11 @@ mod tests { #[test] fn headers_incomplete() { - const data: &'static [u8] = + const DATA: &'static [u8] = b"Host: foo.com\r\n\ Connection: Upgrade\r\n\ Upgrade: websocket\r\n"; - let hdr = Headers::try_parse(data).unwrap(); + let hdr = Headers::try_parse(DATA).unwrap(); assert!(hdr.is_none()); } diff --git a/src/handshake/server.rs b/src/handshake/server.rs index 2498891..d389fd3 100644 --- a/src/handshake/server.rs +++ b/src/handshake/server.rs @@ -99,15 +99,15 @@ mod tests { #[test] fn request_parsing() { - const data: &'static [u8] = b"GET /script.ws HTTP/1.1\r\nHost: foo.com\r\n\r\n"; - let (_, req) = Request::try_parse(data).unwrap().unwrap(); + const DATA: &'static [u8] = b"GET /script.ws HTTP/1.1\r\nHost: foo.com\r\n\r\n"; + let (_, req) = Request::try_parse(DATA).unwrap().unwrap(); assert_eq!(req.path, "/script.ws"); assert_eq!(req.headers.find_first("Host"), Some(&b"foo.com"[..])); } #[test] fn request_replying() { - const data: &'static [u8] = b"\ + const DATA: &'static [u8] = b"\ GET /script.ws HTTP/1.1\r\n\ Host: foo.com\r\n\ Connection: upgrade\r\n\ @@ -115,7 +115,7 @@ mod tests { Sec-WebSocket-Version: 13\r\n\ Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==\r\n\ \r\n"; - let (_, req) = Request::try_parse(data).unwrap().unwrap(); + let (_, req) = Request::try_parse(DATA).unwrap().unwrap(); let _ = req.reply().unwrap(); } diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index ab811a9..0749dad 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -1,6 +1,7 @@ //! Generic WebSocket protocol implementation -mod frame; +pub mod frame; + mod message; pub use self::message::Message;