summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/ops/websocket.rs12
-rw-r--r--cli/rt/27_websocket.js2
2 files changed, 8 insertions, 6 deletions
diff --git a/cli/ops/websocket.rs b/cli/ops/websocket.rs
index 6c4d079b6..23dee5f85 100644
--- a/cli/ops/websocket.rs
+++ b/cli/ops/websocket.rs
@@ -68,11 +68,13 @@ pub async fn op_ws_create(
cli_state.flags.ca_file.clone()
};
let uri: Uri = args.url.parse()?;
- let request = Request::builder()
- .method(Method::GET)
- .uri(&uri)
- .header("Sec-WebSocket-Protocol", args.protocols)
- .body(())?;
+ let mut request = Request::builder().method(Method::GET).uri(&uri);
+
+ if !args.protocols.is_empty() {
+ request = request.header("Sec-WebSocket-Protocol", args.protocols);
+ }
+
+ let request = request.body(())?;
let domain = &uri.host().unwrap().to_string();
let port = &uri.port_u16().unwrap_or(match uri.scheme_str() {
Some("wss") => 443,
diff --git a/cli/rt/27_websocket.js b/cli/rt/27_websocket.js
index 76070ebee..98d3a21e6 100644
--- a/cli/rt/27_websocket.js
+++ b/cli/rt/27_websocket.js
@@ -48,7 +48,7 @@
core.jsonOpAsync("op_ws_create", {
url: wsURL.href,
- protocols: protocols.join("; "),
+ protocols: protocols.join(", "),
}).then((create) => {
if (create.success) {
this.#rid = create.rid;