diff options
author | nerix <nero.9@hotmail.de> | 2020-10-22 17:09:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-22 17:09:44 +0200 |
commit | 0a2f0fe7f23a1b3ffa8dedf18694f2e5924a9880 (patch) | |
tree | 2878a4128e83eb0d60f4835186247957d3dd88a6 /cli/ops/websocket.rs | |
parent | 4b43f8cffadf8ac5e9e258afaaa5887fc1975884 (diff) |
fix(cli/rt/websockets): Only add Sec-WebSocket-Protocol if it's not empty (#7936)
Diffstat (limited to 'cli/ops/websocket.rs')
-rw-r--r-- | cli/ops/websocket.rs | 12 |
1 files changed, 7 insertions, 5 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, |