From fe9edec56be716c2069211d1287896ed96a4ff91 Mon Sep 17 00:00:00 2001 From: Daniel Abramov Date: Sun, 2 Jun 2024 12:53:50 +0200 Subject: [PATCH] Prepare 0.23.0 release --- CHANGELOG.md | 7 ++++++- Cargo.toml | 9 ++++----- examples/autobahn-client.rs | 18 ++++-------------- examples/client.rs | 6 ++---- examples/server-headers.rs | 4 +--- tests/communication.rs | 2 +- tests/handshakes.rs | 2 +- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b816a633..d38a0f9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ +# 0.23.0 + +- Update `tungstenite` to `0.23.0`. +- Disable default features on TLS crates. + # 0.22.0 - Update TLS dependencies. -- Update `tungstenite` to match `0.22.0`. +- ~~Update `tungstenite` to match `0.22.0`.~~ # 0.21.0 diff --git a/Cargo.toml b/Cargo.toml index 6f76a5c8..6c718a0b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,15 +6,15 @@ keywords = ["websocket", "io", "web"] authors = ["Daniel Abramov ", "Alexey Galakhov "] license = "MIT" homepage = "https://github.com/snapview/tokio-tungstenite" -documentation = "https://docs.rs/tokio-tungstenite/0.22.0" +documentation = "https://docs.rs/tokio-tungstenite/0.23.0" repository = "https://github.com/snapview/tokio-tungstenite" -version = "0.22.0" +version = "0.23.0" edition = "2018" rust-version = "1.63" include = ["examples/**/*", "src/**/*", "LICENSE", "README.md", "CHANGELOG.md"] [package.metadata.docs.rs] -features = ["native-tls", "__rustls-tls"] +all-features = true [features] default = ["connect", "handshake"] @@ -33,7 +33,7 @@ futures-util = { version = "0.3.28", default-features = false, features = ["sink tokio = { version = "1.0.0", default-features = false, features = ["io-util"] } [dependencies.tungstenite] -version = "0.21.0" +version = "0.23.0" default-features = false [dependencies.native-tls-crate] @@ -73,7 +73,6 @@ hyper = { version = "1.0", default-features = false, features = ["http1", "serve hyper-util = { version = "0.1", features = ["tokio"] } http-body-util = "0.1" tokio = { version = "1.27.0", default-features = false, features = ["io-std", "macros", "net", "rt-multi-thread", "time"] } -url = "2.3.1" env_logger = "0.10.0" [[example]] diff --git a/examples/autobahn-client.rs b/examples/autobahn-client.rs index 86b765b0..7c87c170 100644 --- a/examples/autobahn-client.rs +++ b/examples/autobahn-client.rs @@ -4,36 +4,26 @@ use tokio_tungstenite::{ connect_async, tungstenite::{Error, Result}, }; -use url::Url; const AGENT: &str = "Tungstenite"; async fn get_case_count() -> Result { - let (mut socket, _) = connect_async( - Url::parse("ws://localhost:9001/getCaseCount").expect("Can't connect to case count URL"), - ) - .await?; + let (mut socket, _) = connect_async("ws://localhost:9001/getCaseCount").await?; let msg = socket.next().await.expect("Can't fetch case count")?; socket.close(None).await?; Ok(msg.into_text()?.parse::().expect("Can't parse case count")) } async fn update_reports() -> Result<()> { - let (mut socket, _) = connect_async( - Url::parse(&format!("ws://localhost:9001/updateReports?agent={}", AGENT)) - .expect("Can't update reports"), - ) - .await?; + let (mut socket, _) = + connect_async(&format!("ws://localhost:9001/updateReports?agent={}", AGENT)).await?; socket.close(None).await?; Ok(()) } async fn run_test(case: u32) -> Result<()> { info!("Running test case {}", case); - let case_url = - Url::parse(&format!("ws://localhost:9001/runCase?case={}&agent={}", case, AGENT)) - .expect("Bad testcase URL"); - + let case_url = &format!("ws://localhost:9001/runCase?case={}&agent={}", case, AGENT); let (mut ws_stream, _) = connect_async(case_url).await?; while let Some(msg) = ws_stream.next().await { let msg = msg?; diff --git a/examples/client.rs b/examples/client.rs index 58fa960e..05a73757 100644 --- a/examples/client.rs +++ b/examples/client.rs @@ -18,15 +18,13 @@ use tokio_tungstenite::{connect_async, tungstenite::protocol::Message}; #[tokio::main] async fn main() { - let connect_addr = + let url = env::args().nth(1).unwrap_or_else(|| panic!("this program requires at least one argument")); - let url = url::Url::parse(&connect_addr).unwrap(); - let (stdin_tx, stdin_rx) = futures_channel::mpsc::unbounded(); tokio::spawn(read_stdin(stdin_tx)); - let (ws_stream, _) = connect_async(url).await.expect("Failed to connect"); + let (ws_stream, _) = connect_async(&url).await.expect("Failed to connect"); println!("WebSocket handshake has been successfully completed"); let (write, read) = ws_stream.split(); diff --git a/examples/server-headers.rs b/examples/server-headers.rs index 014c454a..f8b729f6 100644 --- a/examples/server-headers.rs +++ b/examples/server-headers.rs @@ -18,7 +18,6 @@ use tokio_tungstenite::{ Message, }, }; -use url::Url; #[macro_use] extern crate log; use futures_util::{SinkExt, StreamExt}; @@ -69,8 +68,7 @@ async fn accept_connection(stream: TcpStream) { } fn client() { - let (mut socket, response) = - connect(Url::parse("ws://localhost:8080/socket").unwrap()).expect("Can't connect"); + let (mut socket, response) = connect("ws://localhost:8080/socket").expect("Can't connect"); debug!("Connected to the server"); debug!("Response HTTP code: {}", response.status()); debug!("Response contains the following headers:"); diff --git a/tests/communication.rs b/tests/communication.rs index 06a53197..1196a228 100644 --- a/tests/communication.rs +++ b/tests/communication.rs @@ -89,7 +89,7 @@ async fn split_communication() { con_rx.await.expect("Server not ready"); let tcp = TcpStream::connect("127.0.0.1:12346").await.expect("Failed to connect"); - let url = url::Url::parse("ws://localhost:12345/").unwrap(); + let url = "ws://localhost:12345/"; let (stream, _) = client_async(url, tcp).await.expect("Client failed to connect"); let (mut tx, _rx) = stream.split(); diff --git a/tests/handshakes.rs b/tests/handshakes.rs index bcbfc1a4..8d4fbff2 100644 --- a/tests/handshakes.rs +++ b/tests/handshakes.rs @@ -20,6 +20,6 @@ async fn handshakes() { rx.await.expect("Failed to wait for server to be ready"); let tcp = TcpStream::connect("127.0.0.1:12345").await.expect("Failed to connect"); - let url = url::Url::parse("ws://localhost:12345/").unwrap(); + let url = "ws://localhost:12345/"; let _stream = client_async(url, tcp).await.expect("Client failed to connect"); }