From b5263a06fac623c70911f4ac9c23d9f6250187f7 Mon Sep 17 00:00:00 2001 From: Toshit Chawda Date: Tue, 2 Jul 2024 21:09:09 -0700 Subject: [PATCH] add useragent to ws requests --- Cargo.lock | 2 +- client/Cargo.toml | 2 +- client/package.json | 2 +- client/src/lib.rs | 2 +- client/src/websocket.rs | 6 ++++-- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 83ce47b..675a0dc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -522,7 +522,7 @@ checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" [[package]] name = "epoxy-client" -version = "2.0.0" +version = "2.0.2" dependencies = [ "async-compression", "async-trait", diff --git a/client/Cargo.toml b/client/Cargo.toml index 6d122c9..1c88c57 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "epoxy-client" -version = "2.0.1" +version = "2.0.2" edition = "2021" [lib] diff --git a/client/package.json b/client/package.json index 3de9e3a..efaeb73 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "@mercuryworkshop/epoxy-tls", - "version": "2.0.1-1", + "version": "2.0.2-1", "description": "A wasm library for using raw encrypted tls/ssl/https/websocket streams on the browser", "scripts": { "build": "./build.sh" diff --git a/client/src/lib.rs b/client/src/lib.rs index 1fe3f75..cd00141 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -247,7 +247,7 @@ impl EpoxyClient { protocols: Vec, headers: JsValue, ) -> Result { - EpoxyWebSocket::connect(self, handlers, url, protocols, headers).await + EpoxyWebSocket::connect(self, handlers, url, protocols, headers, &self.user_agent).await } pub async fn connect_tcp( diff --git a/client/src/websocket.rs b/client/src/websocket.rs index 67d1a73..06e5dff 100644 --- a/client/src/websocket.rs +++ b/client/src/websocket.rs @@ -9,7 +9,7 @@ use futures_util::lock::Mutex; use getrandom::getrandom; use http::{ header::{ - CONNECTION, HOST, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE, + CONNECTION, HOST, SEC_WEBSOCKET_KEY, SEC_WEBSOCKET_PROTOCOL, SEC_WEBSOCKET_VERSION, UPGRADE, USER_AGENT, }, Method, Request, Response, StatusCode, Uri, }; @@ -38,6 +38,7 @@ impl EpoxyWebSocket { url: String, protocols: Vec, headers: JsValue, + user_agent: &str, ) -> Result { let EpoxyHandlers { onopen, @@ -61,7 +62,8 @@ impl EpoxyWebSocket { .header(CONNECTION, "upgrade") .header(UPGRADE, "websocket") .header(SEC_WEBSOCKET_KEY, key) - .header(SEC_WEBSOCKET_VERSION, "13"); + .header(SEC_WEBSOCKET_VERSION, "13") + .header(USER_AGENT, user_agent); if !protocols.is_empty() { request = request.header(SEC_WEBSOCKET_PROTOCOL, protocols.join(","));