summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-09-06 08:15:00 +1000
committerGitHub <noreply@github.com>2024-09-06 08:15:00 +1000
commit7937ae3f2f5a8c11f52c42676ba56d12fcb59aeb (patch)
tree1bfb9d994ef638bc26dc9c643e6eca35c2a7ccd9 /cli/tsc
parent6919f33216bb1db2b3596ca6f2f9c2c54f322720 (diff)
chore(net): soft-remove `Deno.serveHttp()` (#25451)
Towards #22079 --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts135
1 files changed, 15 insertions, 120 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index fe845bd5f..4cd97c531 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -4777,110 +4777,6 @@ declare namespace Deno {
mtime: number | Date,
): Promise<void>;
- /** The event yielded from an {@linkcode HttpConn} which represents an HTTP
- * request from a remote client.
- *
- * @category HTTP Server
- *
- * @deprecated This will be removed in Deno 2.0. See the
- * {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
- * for migration instructions.
- */
- export interface RequestEvent {
- /** The request from the client in the form of the web platform
- * {@linkcode Request}. */
- readonly request: Request;
- /** The method to be used to respond to the event. The response needs to
- * either be an instance of {@linkcode Response} or a promise that resolves
- * with an instance of `Response`.
- *
- * When the response is successfully processed then the promise returned
- * will be resolved. If there are any issues with sending the response,
- * the promise will be rejected. */
- respondWith(r: Response | PromiseLike<Response>): Promise<void>;
- }
-
- /**
- * The async iterable that is returned from {@linkcode serveHttp} which
- * yields up {@linkcode RequestEvent} events, representing individual
- * requests on the HTTP server connection.
- *
- * @category HTTP Server
- *
- * @deprecated This will be removed in Deno 2.0. See the
- * {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
- * for migration instructions.
- */
- export interface HttpConn extends AsyncIterable<RequestEvent>, Disposable {
- /** The resource ID associated with this connection. Generally users do not
- * need to be aware of this identifier. */
- readonly rid: number;
-
- /** An alternative to the async iterable interface which provides promises
- * which resolve with either a {@linkcode RequestEvent} when there is
- * another request or `null` when the client has closed the connection. */
- nextRequest(): Promise<RequestEvent | null>;
- /** Initiate a server side closure of the connection, indicating to the
- * client that you refuse to accept any more requests on this connection.
- *
- * Typically the client closes the connection, which will result in the
- * async iterable terminating or the `nextRequest()` method returning
- * `null`. */
- close(): void;
- }
-
- /**
- * Provides an interface to handle HTTP request and responses over TCP or TLS
- * connections. The method returns an {@linkcode HttpConn} which yields up
- * {@linkcode RequestEvent} events, which utilize the web platform standard
- * {@linkcode Request} and {@linkcode Response} objects to handle the request.
- *
- * ```ts
- * const conn = Deno.listen({ port: 80 });
- * const httpConn = Deno.serveHttp(await conn.accept());
- * const e = await httpConn.nextRequest();
- * if (e) {
- * e.respondWith(new Response("Hello World"));
- * }
- * ```
- *
- * Alternatively, you can also use the async iterator approach:
- *
- * ```ts
- * async function handleHttp(conn: Deno.Conn) {
- * for await (const e of Deno.serveHttp(conn)) {
- * e.respondWith(new Response("Hello World"));
- * }
- * }
- *
- * for await (const conn of Deno.listen({ port: 80 })) {
- * handleHttp(conn);
- * }
- * ```
- *
- * If `httpConn.nextRequest()` encounters an error or returns `null` then the
- * underlying {@linkcode HttpConn} resource is closed automatically.
- *
- * Also see the experimental Flash HTTP server {@linkcode Deno.serve} which
- * provides a ground up rewrite of handling of HTTP requests and responses
- * within the Deno CLI.
- *
- * Note that this function *consumes* the given connection passed to it, thus
- * the original connection will be unusable after calling this. Additionally,
- * you need to ensure that the connection is not being used elsewhere when
- * calling this function in order for the connection to be consumed properly.
- *
- * For instance, if there is a `Promise` that is waiting for read operation on
- * the connection to complete, it is considered that the connection is being
- * used elsewhere. In such a case, this function will fail.
- *
- * @category HTTP Server
- * @deprecated This will be soft-removed in Deno 2.0. See the
- * {@link https://docs.deno.com/runtime/manual/advanced/migrate_deprecations | Deno 1.x to 2.x Migration Guide}
- * for migration instructions.
- */
- export function serveHttp(conn: Conn): HttpConn;
-
/** The object that is returned from a {@linkcode Deno.upgradeWebSocket}
* request.
*
@@ -4923,22 +4819,21 @@ declare namespace Deno {
* with the returned response for the websocket upgrade to be successful.
*
* ```ts
- * const conn = Deno.listen({ port: 80 });
- * const httpConn = Deno.serveHttp(await conn.accept());
- * 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);
- * e.respondWith(response);
- * }
+ * Deno.serve((req) => {
+ * if (req.headers.get("upgrade") !== "websocket") {
+ * return new Response(null, { status: 501 });
+ * }
+ * const { socket, response } = Deno.upgradeWebSocket(req);
+ * socket.addEventListener("open", () => {
+ * console.log("a client connected!");
+ * });
+ * socket.addEventListener("message", (event) => {
+ * if (event.data === "ping") {
+ * socket.send("pong");
+ * }
+ * });
+ * return response;
+ * });
* ```
*
* If the request body is disturbed (read from) before the upgrade is