diff --git a/cli/ops/websocket.rs b/cli/ops/websocket.rs index 6c4d079b6b..23dee5f858 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 76070ebee4..98d3a21e65 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;