From 85c2887b3086c2f207f6be4c42ec83522052fb72 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 17 Mar 2019 21:09:50 -0700 Subject: [PATCH] export ws::hash_key --- src/error.rs | 43 ------------------------------------------- src/ws/mod.rs | 2 +- src/ws/proto.rs | 2 +- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/src/error.rs b/src/error.rs index e0a416ef8..6bc401332 100644 --- a/src/error.rs +++ b/src/error.rs @@ -981,23 +981,6 @@ mod tests { from!(httparse::Error::Version => ParseError::Version); } - // #[test] - // fn failure_error() { - // const NAME: &str = "RUST_BACKTRACE"; - // let old_tb = env::var(NAME); - // env::set_var(NAME, "0"); - // let error = failure::err_msg("Hello!"); - // let resp: Error = error.into(); - // assert_eq!( - // format!("{:?}", resp), - // "Compat { error: ErrorMessage { msg: \"Hello!\" } }\n\n" - // ); - // match old_tb { - // Ok(x) => env::set_var(NAME, x), - // _ => env::remove_var(NAME), - // } - // } - #[test] fn test_internal_error() { let err = @@ -1006,32 +989,6 @@ mod tests { assert_eq!(resp.status(), StatusCode::OK); } - // #[test] - // fn test_error_downcasting_direct() { - // #[derive(Debug, Display)] - // #[display(fmt = "demo error")] - // struct DemoError; - - // impl ResponseError for DemoError {} - - // let err: Error = DemoError.into(); - // let err_ref: &DemoError = err.downcast_ref().unwrap(); - // assert_eq!(err_ref.to_string(), "demo error"); - // } - - // #[test] - // fn test_error_downcasting_compat() { - // #[derive(Debug, Display)] - // #[display(fmt = "demo error")] - // struct DemoError; - - // impl ResponseError for DemoError {} - - // let err: Error = failure::Error::from(DemoError).into(); - // let err_ref: &DemoError = err.downcast_ref().unwrap(); - // assert_eq!(err_ref.to_string(), "demo error"); - // } - #[test] fn test_error_helpers() { let r: Response = ErrorBadRequest("err").into(); diff --git a/src/ws/mod.rs b/src/ws/mod.rs index 8f9bc83ba..3d3f5b925 100644 --- a/src/ws/mod.rs +++ b/src/ws/mod.rs @@ -24,7 +24,7 @@ mod transport; pub use self::client::{Client, ClientError, Connect}; pub use self::codec::{Codec, Frame, Message}; pub use self::frame::Parser; -pub use self::proto::{CloseCode, CloseReason, OpCode}; +pub use self::proto::{hash_key, CloseCode, CloseReason, OpCode}; pub use self::service::VerifyWebSockets; pub use self::transport::Transport; diff --git a/src/ws/proto.rs b/src/ws/proto.rs index 35fbbe3ee..eef874741 100644 --- a/src/ws/proto.rs +++ b/src/ws/proto.rs @@ -209,7 +209,7 @@ impl> From<(CloseCode, T)> for CloseReason { static WS_GUID: &'static str = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; // TODO: hash is always same size, we dont need String -pub(crate) fn hash_key(key: &[u8]) -> String { +pub fn hash_key(key: &[u8]) -> String { let mut hasher = sha1::Sha1::new(); hasher.update(key);