diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2021-04-09 00:34:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-08 18:34:15 -0400 |
commit | 70af8128767f2fc5a9c59107d3b5ddc00531db55 (patch) | |
tree | 48513959f16273eab2c4b743d61042b00a72deb8 /cli/dts/lib.deno.unstable.d.ts | |
parent | b30ac9c5cf58c34ed71d2f470cdbcd86a6096987 (diff) |
feat: native HTTP bindings (#9935)
Co-authered-by: Luca Casonato <lucacasonato@yahoo.com>
Co-authered-by: Ben Noordhuis <info@bnoordhuis.nl>
Co-authered-by: Ryan Dahl <ry@tinyclouds.org>
Diffstat (limited to 'cli/dts/lib.deno.unstable.d.ts')
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 0833c3301..9dbe6817f 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1196,6 +1196,33 @@ declare namespace Deno { bytesSentData: number; bytesReceived: number; } + + export interface RequestEvent { + readonly request: Request; + respondWith(r: Response | Promise<Response>): void; + } + + export interface HttpConn extends AsyncIterable<RequestEvent> { + readonly rid: number; + + nextRequest(): Promise<RequestEvent | null>; + close(): void; + } + + /** **UNSTABLE**: new API, yet to be vetted. + * + * Parse HTTP requests from the given connection + * + * ```ts + * const httpConn = await Deno.startHttp(conn); + * const { request, respondWith } = await httpConn.next(); + * respondWith(new Response("Hello World")); + * ``` + * + * If `httpConn.next()` encounters an error or returns `done == true` then + * the underlying HttpConn resource is closed automatically. + */ + export function startHttp(conn: Conn): HttpConn; } declare function fetch( |