Services HTTP requests given a TCP or TLS socket.
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.
Parameters
conn: Conn