diff --git a/Cargo.toml b/Cargo.toml index 506c714..be5df8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,19 +26,19 @@ http-body-util = "0.1.0" hyper = "1.1.0" hyper-rustls = { version = "0.27.0", default-features = false, features = ["http1", "logging", "tls12", "webpki-tokio"], optional = true } hyper-tls = { version = "0.6.0", optional = true } -hyper-tungstenite = "0.15.0" +hyper-tungstenite = "0.17.0" hyper-util = { version="0.1.3", features = ["client-legacy", "server", "http1"] } moka = { version = "0.12.0", features = ["future"], optional = true } openssl = { version = "0.10.46", optional = true } rand = { version = "0.8.0", optional = true } rcgen = { version = "0.13.0", features = ["x509-parser"], optional = true } -thiserror = "2.0.0" +thiserror = "2.0.7" time = { version = "0.3.35", optional = true } tokio = { version = "1.24.2", features = ["macros", "rt"] } tokio-graceful = "0.2.0" tokio-native-tls = { version = "0.3.1", optional = true } tokio-rustls = { version = "0.26.0", features = ["logging", "tls12"] } -tokio-tungstenite = "0.24.0" +tokio-tungstenite = "0.26.1" tokio-util = { version = "0.7.1", features = ["io"], optional = true } tracing = { version = "0.1.35", features = ["log"] } diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 9a3fb5e..a4190c1 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -16,7 +16,7 @@ use hudsucker::{ server::conn::auto, }, rustls, - tokio_tungstenite::tungstenite::Message, + tokio_tungstenite::tungstenite::{Message, Utf8Bytes}, Body, HttpContext, HttpHandler, Proxy, RequestOrResponse, WebSocketContext, WebSocketHandler, }; use reqwest::tls::Certificate; @@ -34,8 +34,8 @@ use tokio_graceful::Shutdown; use tokio_native_tls::native_tls; use tokio_util::io::ReaderStream; -pub const HELLO_WORLD: &str = "Hello, World!"; -pub const WORLD: &str = "world"; +pub const HELLO_WORLD: &str = "Hello, World"; +pub const WORLD: Utf8Bytes = Utf8Bytes::from_static("world"); async fn test_server(req: Request) -> Result, Infallible> { if hyper_tungstenite::is_upgrade_request(&req) { @@ -49,7 +49,7 @@ async fn test_server(req: Request) -> Result, Infallibl if msg.is_close() { break; } - ws.send(Message::Text(WORLD.to_owned())).await.unwrap(); + ws.send(Message::Text(WORLD)).await.unwrap(); } }); diff --git a/tests/websocket.rs b/tests/websocket.rs index c2fe1fd..0653cf0 100644 --- a/tests/websocket.rs +++ b/tests/websocket.rs @@ -4,7 +4,7 @@ use hudsucker::{ certificate_authority::RcgenAuthority, rcgen::{CertificateParams, KeyPair}, rustls::crypto::aws_lc_rs, - tokio_tungstenite::tungstenite::Message, + tokio_tungstenite::tungstenite::{Message, Utf8Bytes}, }; use std::sync::atomic::Ordering; use tokio::net::TcpStream; @@ -12,6 +12,8 @@ use tokio::net::TcpStream; #[allow(unused)] mod common; +const HELLO: Utf8Bytes = Utf8Bytes::from_static("hello"); + fn build_ca() -> RcgenAuthority { let key_pair = include_str!("../examples/ca/hudsucker.key"); let ca_cert = include_str!("../examples/ca/hudsucker.cer"); @@ -49,11 +51,11 @@ async fn http() { .await .unwrap(); - ws.send(Message::Text("hello".to_owned())).await.unwrap(); + ws.send(Message::Text(HELLO)).await.unwrap(); let msg = ws.next().await.unwrap().unwrap(); - assert_eq!(msg.to_string(), common::WORLD); + assert_eq!(msg.into_text().unwrap(), common::WORLD); assert_eq!(handler.message_counter.load(Ordering::Relaxed), 2); stop_server.send(()).unwrap(); @@ -86,11 +88,11 @@ async fn https_rustls() { .await .unwrap(); - ws.send(Message::Text("hello".to_owned())).await.unwrap(); + ws.send(Message::Text(HELLO)).await.unwrap(); let msg = ws.next().await.unwrap().unwrap(); - assert_eq!(msg.to_string(), common::WORLD); + assert_eq!(msg.into_text().unwrap(), common::WORLD); assert_eq!(handler.message_counter.load(Ordering::Relaxed), 2); stop_server.send(()).unwrap(); @@ -123,11 +125,11 @@ async fn https_native_tls() { .await .unwrap(); - ws.send(Message::Text("hello".to_owned())).await.unwrap(); + ws.send(Message::Text(HELLO)).await.unwrap(); let msg = ws.next().await.unwrap().unwrap(); - assert_eq!(msg.to_string(), common::WORLD); + assert_eq!(msg.into_text().unwrap(), common::WORLD); assert_eq!(handler.message_counter.load(Ordering::Relaxed), 2); stop_server.send(()).unwrap(); @@ -159,11 +161,11 @@ async fn without_intercept() { .await .unwrap(); - ws.send(Message::Text("hello".to_owned())).await.unwrap(); + ws.send(Message::Text(HELLO)).await.unwrap(); let msg = ws.next().await.unwrap().unwrap(); - assert_eq!(msg.to_string(), common::WORLD); + assert_eq!(msg.into_text().unwrap(), common::WORLD); assert_eq!(handler.message_counter.load(Ordering::Relaxed), 0); stop_server.send(()).unwrap(); @@ -188,10 +190,10 @@ async fn noop() { .await .unwrap(); - ws.send(Message::Text("hello".to_owned())).await.unwrap(); + ws.send(Message::Text(HELLO)).await.unwrap(); let msg = ws.next().await.unwrap().unwrap(); - assert_eq!(msg.to_string(), common::WORLD); + assert_eq!(msg.into_text().unwrap(), common::WORLD); stop_server.send(()).unwrap(); stop_proxy.send(()).unwrap();