1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 07:14:47 -05:00

fix(cli/rt/websockets): Only add Sec-WebSocket-Protocol if it's not empty (#7936)

This commit is contained in:
nerix 2020-10-22 17:09:44 +02:00 committed by GitHub
parent 4b43f8cffa
commit 0a2f0fe7f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 6 deletions

View file

@ -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,

View file

@ -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;