From c5270abad7c42968dcbdbc8d9f09d7675fb843e9 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 16 Mar 2022 14:54:18 +0100 Subject: feat(unstable): Add Deno.upgradeHttp API (#13618) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds "Deno.upgradeHttp" API, which allows to "hijack" connection and switch protocols, to eg. implement WebSocket required for Node compat. Co-authored-by: crowlkats Co-authored-by: Ryan Dahl Co-authored-by: Bartek IwaƄczuk --- cli/dts/lib.deno.unstable.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cli/dts/lib.deno.unstable.d.ts') diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 9ab9b5761..a61d672f7 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1333,6 +1333,20 @@ declare namespace Deno { * Make the timer of the given id not blocking the event loop from finishing */ export function unrefTimer(id: number): void; + + /** **UNSTABLE**: new API, yet to be vetter. + * + * Allows to "hijack" a connection that the request is associated with. + * Can be used to implement protocols that build on top of HTTP (eg. + * WebSockets). + * + * The returned promise returns underlying connection and first packet + * received. The promise shouldn't be awaited before responding to the + * `request`, otherwise event loop might deadlock. + */ + export function upgradeHttp( + request: Request, + ): Promise<[Deno.Conn, Uint8Array]>; } declare function fetch( -- cgit v1.2.3