diff options
author | Bert Belder <bertbelder@gmail.com> | 2022-03-16 14:54:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-16 14:54:18 +0100 |
commit | c5270abad7c42968dcbdbc8d9f09d7675fb843e9 (patch) | |
tree | 7e7ff9b63b7cd3420295d5e546dcd987ed746d7d /cli/dts/lib.deno.unstable.d.ts | |
parent | 89a41d0a67c531d937126bbdb095ab1edb5eede2 (diff) |
feat(unstable): Add Deno.upgradeHttp API (#13618)
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 <crowlkats@toaxl.com>
Co-authored-by: Ryan Dahl <ry@tinyclouds.org>
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/dts/lib.deno.unstable.d.ts')
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 14 |
1 files changed, 14 insertions, 0 deletions
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( |