1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: remove unused, unstable 'http' namespace (#23436)

Landing parts of #21903 in preparation for the removal of serveHttp.
This commit is contained in:
Matt Mastracci 2024-04-18 11:21:25 -06:00 committed by GitHub
parent 6a09a16d71
commit d9d3f81f29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 21 additions and 84 deletions

View file

@ -4,11 +4,13 @@ import { core, internals, primordials } from "ext:core/mod.js";
const {
BadResourcePrototype,
InterruptedPrototype,
internalRidSymbol,
} = core;
import {
op_http_accept,
op_http_headers,
op_http_shutdown,
op_http_start,
op_http_upgrade_websocket,
op_http_websocket_accept_header,
op_http_write,
@ -71,7 +73,6 @@ import {
readableStreamForRid,
ReadableStreamPrototype,
} from "ext:deno_web/06_streams.js";
import { serve } from "ext:deno_http/00_serve.js";
import { SymbolDispose } from "ext:deno_web/00_infra.js";
const connErrorSymbol = Symbol("connError");
@ -557,4 +558,14 @@ function buildCaseInsensitiveCommaValueFinder(checkText) {
internals.buildCaseInsensitiveCommaValueFinder =
buildCaseInsensitiveCommaValueFinder;
export { _ws, HttpConn, serve, upgradeWebSocket };
function serveHttp(conn) {
internals.warnOnDeprecatedApi(
"Deno.serveHttp()",
new Error().stack,
"Use `Deno.serve()` instead.",
);
const rid = op_http_start(conn[internalRidSymbol]);
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
}
export { _ws, HttpConn, serveHttp, upgradeWebSocket };

View file

@ -1,18 +0,0 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { core, internals } from "ext:core/mod.js";
import { op_http_start } from "ext:core/ops";
const { internalRidSymbol } = core;
import { HttpConn } from "ext:deno_http/01_http.js";
function serveHttp(conn) {
internals.warnOnDeprecatedApi(
"Deno.serveHttp()",
new Error().stack,
"Use `Deno.serve()` instead.",
);
const rid = op_http_start(conn[internalRidSymbol]);
return new HttpConn(rid, conn.remoteAddr, conn.localAddr);
}
export { serveHttp };

View file

@ -13,6 +13,7 @@ import * as console from "ext:deno_console/01_console.js";
import * as ffi from "ext:deno_ffi/00_ffi.js";
import * as net from "ext:deno_net/01_net.js";
import * as tls from "ext:deno_net/02_tls.js";
import * as serve from "ext:deno_http/00_serve.js";
import * as http from "ext:deno_http/01_http.js";
import * as errors from "ext:runtime/01_errors.js";
import * as version from "ext:runtime/01_version.ts";
@ -25,8 +26,6 @@ import * as fsEvents from "ext:runtime/40_fs_events.js";
import * as process from "ext:runtime/40_process.js";
import * as signals from "ext:runtime/40_signals.js";
import * as tty from "ext:runtime/40_tty.js";
// TODO(bartlomieju): this is funky we have two `http` imports
import * as httpRuntime from "ext:runtime/40_http.js";
import * as kv from "ext:deno_kv/01_db.ts";
import * as cron from "ext:deno_cron/01_cron.ts";
import * as webgpuSurface from "ext:deno_webgpu/02_surface.js";
@ -225,9 +224,8 @@ const denoNs = {
permissions: permissions.permissions,
Permissions: permissions.Permissions,
PermissionStatus: permissions.PermissionStatus,
// TODO(bartlomieju): why is this not in one of extensions?
serveHttp: httpRuntime.serveHttp,
serve: http.serve,
serveHttp: http.serveHttp,
serve: serve.serve,
resolveDns: net.resolveDns,
upgradeWebSocket: http.upgradeWebSocket,
utime: fs.utime,
@ -292,8 +290,6 @@ denoNsUnstableById[unstableIds.fs] = {
denoNsUnstableById[unstableIds.http] = {
HttpClient: httpClient.HttpClient,
createHttpClient: httpClient.createHttpClient,
// TODO(bartlomieju): why is it needed?
http,
};
denoNsUnstableById[unstableIds.kv] = {
@ -328,8 +324,6 @@ const denoNsUnstable = {
umask: fs.umask,
HttpClient: httpClient.HttpClient,
createHttpClient: httpClient.createHttpClient,
// TODO(bartlomieju): why is it needed?
http,
dlopen: ffi.dlopen,
UnsafeCallback: ffi.UnsafeCallback,
UnsafePointer: ffi.UnsafePointer,

View file

@ -45,7 +45,6 @@ extension!(runtime,
"13_buffer.js",
"30_os.js",
"40_fs_events.js",
"40_http.js",
"40_process.js",
"40_signals.js",
"40_tty.js",

View file

@ -1,12 +1,4 @@
main undefined
main undefined
main undefined
main undefined
main undefined
main undefined
worker undefined
worker undefined
worker undefined
worker undefined
worker undefined
worker undefined

View file

@ -1,12 +1,4 @@
main [class HttpClient]
main [Function: createHttpClient]
main [class HttpConn]
main Symbol("[[associated_ws]]")
main [Function: serve]
main [Function: upgradeWebSocket]
worker [class HttpClient]
worker [Function: createHttpClient]
worker [class HttpConn]
worker Symbol("[[associated_ws]]")
worker [Function: serve]
worker [Function: upgradeWebSocket]

View file

@ -2,10 +2,6 @@ const scope = import.meta.url.slice(-7) === "#worker" ? "worker" : "main";
console.log(scope, Deno.HttpClient);
console.log(scope, Deno.createHttpClient);
console.log(scope, Deno.http?.HttpConn);
console.log(scope, Deno.http?._ws);
console.log(scope, Deno.http?.serve);
console.log(scope, Deno.http?.upgradeWebSocket);
if (scope === "worker") {
postMessage("done");

View file

@ -1249,44 +1249,16 @@ Deno.test({}, function fetchWritableRespProps() {
Deno.test(
{ permissions: { net: true } },
async function fetchFilterOutCustomHostHeader(): Promise<
void
> {
async function fetchFilterOutCustomHostHeader() {
const addr = `127.0.0.1:${listenPort}`;
const [hostname, port] = addr.split(":");
const listener = Deno.listen({
hostname,
port: Number(port),
}) as Deno.Listener;
let httpConn: Deno.HttpConn;
listener.accept().then(async (conn: Deno.Conn) => {
httpConn = Deno.serveHttp(conn);
await httpConn.nextRequest()
.then(async (requestEvent: Deno.RequestEvent | null) => {
const hostHeader = requestEvent?.request.headers.get("Host");
const headersToReturn = hostHeader
? { "Host": hostHeader }
: undefined;
await requestEvent?.respondWith(
new Response("", {
status: 200,
headers: headersToReturn,
}),
);
});
const server = Deno.serve({ port: listenPort }, (req) => {
return new Response(`Host header was ${req.headers.get("Host")}`);
});
const response = await fetch(`http://${addr}/`, {
headers: { "Host": "example.com" },
});
await response.text();
listener.close();
httpConn!.close();
assertEquals(response.headers.get("Host"), addr);
assertEquals(await response.text(), `Host header was ${addr}`);
await server.shutdown();
},
);

View file

@ -237,7 +237,6 @@
"ext:runtime/13_buffer.js": "../runtime/js/13_buffer.js",
"ext:runtime/30_os.js": "../runtime/js/30_os.js",
"ext:runtime/40_fs_events.js": "../runtime/js/40_fs_events.js",
"ext:runtime/40_http.js": "../runtime/js/40_http.js",
"ext:runtime/40_process.js": "../runtime/js/40_process.js",
"ext:runtime/40_signals.js": "../runtime/js/40_signals.js",
"ext:runtime/40_tty.js": "../runtime/js/40_tty.js",