summaryrefslogtreecommitdiff
path: root/ext/http/lib.deno_http.unstable.d.ts
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2021-08-31 11:25:15 +0200
committerGitHub <noreply@github.com>2021-08-31 11:25:15 +0200
commitfcd0992dba9cce0539cc60cd11867f50c0cf5efb (patch)
treee15cb497fce7fa678ab3fce92907dae562faa3b2 /ext/http/lib.deno_http.unstable.d.ts
parentca75752e5a9499a0a997809f02b18c2ba1ecd58d (diff)
fix: move unstable declarations to deno.unstable (#11876)
Diffstat (limited to 'ext/http/lib.deno_http.unstable.d.ts')
-rw-r--r--ext/http/lib.deno_http.unstable.d.ts53
1 files changed, 0 insertions, 53 deletions
diff --git a/ext/http/lib.deno_http.unstable.d.ts b/ext/http/lib.deno_http.unstable.d.ts
deleted file mode 100644
index 5c5bf78df..000000000
--- a/ext/http/lib.deno_http.unstable.d.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-
-/// <reference no-default-lib="true" />
-/// <reference lib="esnext" />
-
-declare namespace Deno {
- export interface WebSocketUpgrade {
- response: Response;
- socket: WebSocket;
- }
-
- export interface UpgradeWebSocketOptions {
- protocol?: string;
- }
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Used to upgrade an incoming HTTP request to a WebSocket.
- *
- * Given a request, returns a pair of WebSocket and Response. The original
- * request must be responded to with the returned response for the websocket
- * upgrade to be successful.
- *
- * ```ts
- * const conn = await Deno.connect({ port: 80, hostname: "127.0.0.1" });
- * const httpConn = Deno.serveHttp(conn);
- * const e = await httpConn.nextRequest();
- * if (e) {
- * const { socket, response } = Deno.upgradeWebSocket(e.request);
- * socket.onopen = () => {
- * socket.send("Hello World!");
- * };
- * socket.onmessage = (e) => {
- * console.log(e.data);
- * socket.close();
- * };
- * socket.onclose = () => console.log("WebSocket has been closed.");
- * socket.onerror = (e) => console.error("WebSocket error:", e.message);
- * e.respondWith(response);
- * }
- * ```
- *
- * If the request body is disturbed (read from) before the upgrade is
- * completed, upgrading fails.
- *
- * This operation does not yet consume the request or open the websocket. This
- * only happens once the returned response has been passed to `respondWith`.
- */
- export function upgradeWebSocket(
- request: Request,
- options?: UpgradeWebSocketOptions,
- ): WebSocketUpgrade;
-}