Skip to content

Commit

Permalink
Prepare 0.23.0 release
Browse files Browse the repository at this point in the history
Also fixes #334.
  • Loading branch information
daniel-abramov committed Jun 2, 2024
1 parent c1025d5 commit a53454b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 29 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ keywords = ["websocket", "io", "web"]
authors = ["Daniel Abramov <dabramov@snapview.de>", "Alexey Galakhov <agalakhov@snapview.de>"]
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"]
Expand All @@ -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]
Expand Down Expand Up @@ -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]]
Expand Down
18 changes: 4 additions & 14 deletions examples/autobahn-client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32> {
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::<u32>().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?;
Expand Down
6 changes: 2 additions & 4 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 1 addition & 3 deletions examples/server-headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use tokio_tungstenite::{
Message,
},
};
use url::Url;
#[macro_use]
extern crate log;
use futures_util::{SinkExt, StreamExt};
Expand Down Expand Up @@ -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:");
Expand Down
2 changes: 1 addition & 1 deletion tests/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion tests/handshakes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

0 comments on commit a53454b

Please sign in to comment.