summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-08-02 14:40:46 +0200
committerGitHub <noreply@github.com>2021-08-02 14:40:46 +0200
commit3a2e94492b0d4df1ae5c3bb5a6a6a899538de10b (patch)
tree3e9b89130f95df5b285a50ef273bbbc32c249605
parentf87aa44d94240327fb4ab1dc756d70f71247edb4 (diff)
feat: stabilize Deno.serveHttp() (#11544)
This commit moves "Deno.serveHttp()" and related types to stable namespace.
-rw-r--r--cli/bench/http.rs1
-rw-r--r--cli/diagnostics.rs3
-rw-r--r--cli/dts/lib.deno.ns.d.ts29
-rw-r--r--cli/dts/lib.deno.unstable.d.ts18
-rw-r--r--extensions/http/lib.deno_http.unstable.d.ts12
-rw-r--r--runtime/js/90_deno_ns.js2
6 files changed, 30 insertions, 35 deletions
diff --git a/cli/bench/http.rs b/cli/bench/http.rs
index 7fdab9844..585867892 100644
--- a/cli/bench/http.rs
+++ b/cli/bench/http.rs
@@ -203,7 +203,6 @@ fn deno_http_native(deno_exe: &str) -> Result<HttpBenchmarkResult> {
"run",
"--allow-net",
"--reload",
- "--unstable",
"cli/bench/deno_http_native.js",
&server_addr(port),
],
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs
index f2c78d5c4..18506ccc8 100644
--- a/cli/diagnostics.rs
+++ b/cli/diagnostics.rs
@@ -25,7 +25,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"EmitOptions",
"EmitResult",
"HttpClient",
- "HttpConn",
"LinuxSignal",
"Location",
"MXRecord",
@@ -33,7 +32,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"Metrics",
"OpMetrics",
"RecordType",
- "RequestEvent",
"ResolveDnsOptions",
"SRVRecord",
"SetRawOptions",
@@ -60,7 +58,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"osRelease",
"ppid",
"resolveDns",
- "serveHttp",
"setRaw",
"shutdown",
"signal",
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 469b8a329..37cc58ad6 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -2414,4 +2414,33 @@ declare namespace Deno {
* ```
*/
export function fstat(rid: number): Promise<FileInfo>;
+
+ export interface RequestEvent {
+ readonly request: Request;
+ respondWith(r: Response | Promise<Response>): Promise<void>;
+ }
+
+ export interface HttpConn extends AsyncIterable<RequestEvent> {
+ readonly rid: number;
+
+ nextRequest(): Promise<RequestEvent | null>;
+ close(): void;
+ }
+
+ /**
+ * Services HTTP requests given a TCP or TLS socket.
+ *
+ * ```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) {
+ * e.respondWith(new Response("Hello World"));
+ * }
+ * ```
+ *
+ * If `httpConn.nextRequest()` encounters an error or returns `null`
+ * then the underlying HttpConn resource is closed automatically.
+ */
+ export function serveHttp(conn: Conn): HttpConn;
}
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index 442da1e53..0ac829463 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -1076,24 +1076,6 @@ declare namespace Deno {
write?: "inherit" | boolean | Array<string | URL>;
};
}
-
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Services HTTP requests given a TCP or TLS socket.
- *
- * ```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) {
- * e.respondWith(new Response("Hello World"));
- * }
- * ```
- *
- * If `httpConn.nextRequest()` encounters an error or returns `null`
- * then the underlying HttpConn resource is closed automatically.
- */
- export function serveHttp(conn: Conn): HttpConn;
}
declare function fetch(
diff --git a/extensions/http/lib.deno_http.unstable.d.ts b/extensions/http/lib.deno_http.unstable.d.ts
index d15da0da6..5c5bf78df 100644
--- a/extensions/http/lib.deno_http.unstable.d.ts
+++ b/extensions/http/lib.deno_http.unstable.d.ts
@@ -4,18 +4,6 @@
/// <reference lib="esnext" />
declare namespace Deno {
- export interface RequestEvent {
- readonly request: Request;
- respondWith(r: Response | Promise<Response>): Promise<void>;
- }
-
- export interface HttpConn extends AsyncIterable<RequestEvent> {
- readonly rid: number;
-
- nextRequest(): Promise<RequestEvent | null>;
- close(): void;
- }
-
export interface WebSocketUpgrade {
response: Response;
socket: WebSocket;
diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js
index 27900431f..aee07eae7 100644
--- a/runtime/js/90_deno_ns.js
+++ b/runtime/js/90_deno_ns.js
@@ -101,6 +101,7 @@
permissions: __bootstrap.permissions.permissions,
Permissions: __bootstrap.permissions.Permissions,
PermissionStatus: __bootstrap.permissions.PermissionStatus,
+ serveHttp: __bootstrap.http.serveHttp,
};
__bootstrap.denoNsUnstable = {
@@ -125,7 +126,6 @@
listen: __bootstrap.netUnstable.listen,
connect: __bootstrap.netUnstable.connect,
listenDatagram: __bootstrap.netUnstable.listenDatagram,
- serveHttp: __bootstrap.http.serveHttp,
startTls: __bootstrap.tls.startTls,
umask: __bootstrap.fs.umask,
upgradeWebSocket: __bootstrap.http.upgradeWebSocket,