From 0a2f0fe7f23a1b3ffa8dedf18694f2e5924a9880 Mon Sep 17 00:00:00 2001 From: nerix Date: Thu, 22 Oct 2020 17:09:44 +0200 Subject: [PATCH] fix(cli/rt/websockets): Only add Sec-WebSocket-Protocol if it's not empty (#7936) --- cli/ops/websocket.rs | 12 +++++++----- cli/rt/27_websocket.js | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) 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;