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:
parent
4b43f8cffa
commit
0a2f0fe7f2
2 changed files with 8 additions and 6 deletions
|
@ -68,11 +68,13 @@ pub async fn op_ws_create(
|
||||||
cli_state.flags.ca_file.clone()
|
cli_state.flags.ca_file.clone()
|
||||||
};
|
};
|
||||||
let uri: Uri = args.url.parse()?;
|
let uri: Uri = args.url.parse()?;
|
||||||
let request = Request::builder()
|
let mut request = Request::builder().method(Method::GET).uri(&uri);
|
||||||
.method(Method::GET)
|
|
||||||
.uri(&uri)
|
if !args.protocols.is_empty() {
|
||||||
.header("Sec-WebSocket-Protocol", args.protocols)
|
request = request.header("Sec-WebSocket-Protocol", args.protocols);
|
||||||
.body(())?;
|
}
|
||||||
|
|
||||||
|
let request = request.body(())?;
|
||||||
let domain = &uri.host().unwrap().to_string();
|
let domain = &uri.host().unwrap().to_string();
|
||||||
let port = &uri.port_u16().unwrap_or(match uri.scheme_str() {
|
let port = &uri.port_u16().unwrap_or(match uri.scheme_str() {
|
||||||
Some("wss") => 443,
|
Some("wss") => 443,
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
core.jsonOpAsync("op_ws_create", {
|
core.jsonOpAsync("op_ws_create", {
|
||||||
url: wsURL.href,
|
url: wsURL.href,
|
||||||
protocols: protocols.join("; "),
|
protocols: protocols.join(", "),
|
||||||
}).then((create) => {
|
}).then((create) => {
|
||||||
if (create.success) {
|
if (create.success) {
|
||||||
this.#rid = create.rid;
|
this.#rid = create.rid;
|
||||||
|
|
Loading…
Reference in a new issue