1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-23 15:16:54 -05:00
denoland-deno/std/http/testdata/simple_https_server.ts
Casper Beyer bee36a4de8
test(std/http): make tests runnable from any directory (#7441)
This makes std/http tests runnable from any directory by spawning test
processes in the module directory resolved from import.meta.url and
resolving test data relative to the same module directory.
2020-09-14 12:58:43 +02:00

18 lines
545 B
TypeScript

// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
// This is an example of a https server
import { serveTLS } from "../server.ts";
const tlsOptions = {
hostname: "localhost",
port: 4503,
certFile: "./testdata/tls/localhost.crt",
keyFile: "./testdata/tls/localhost.key",
};
const s = serveTLS(tlsOptions);
console.log(
`Simple HTTPS server listening on ${tlsOptions.hostname}:${tlsOptions.port}`,
);
const body = new TextEncoder().encode("Hello HTTPS");
for await (const req of s) {
req.respond({ body });
}