From 70b1be6ff459ebd2bf57b7788ab7d66c1f375b29 Mon Sep 17 00:00:00 2001 From: Dreamacro Date: Sat, 4 Jan 2020 17:31:12 +0800 Subject: Fix ws handshake with correctly empty search string (#3587) --- std/ws/mod.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'std/ws/mod.ts') diff --git a/std/ws/mod.ts b/std/ws/mod.ts index a32380efc..c256f58ad 100644 --- a/std/ws/mod.ts +++ b/std/ws/mod.ts @@ -411,13 +411,13 @@ export function createSecKey(): string { return btoa(key); } -async function handshake( +export async function handshake( url: URL, headers: Headers, bufReader: BufReader, bufWriter: BufWriter ): Promise { - const { hostname, pathname, searchParams } = url; + const { hostname, pathname, search } = url; const key = createSecKey(); if (!headers.has("host")) { @@ -428,7 +428,7 @@ async function handshake( headers.set("sec-websocket-key", key); headers.set("sec-websocket-version", "13"); - let headerStr = `GET ${pathname}?${searchParams || ""} HTTP/1.1\r\n`; + let headerStr = `GET ${pathname}${search} HTTP/1.1\r\n`; for (const [key, value] of headers) { headerStr += `${key}: ${value}\r\n`; } -- cgit v1.2.3