From 0644f9c1a6fd85831dac459f50306781ac2b08e3 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Mon, 4 Nov 2019 13:45:29 -0500 Subject: std/http: add serveTLS and listenAndServeTLS (#3257) --- std/http/testdata/simple_https_server.ts | 16 ++++++++++++++++ std/http/testdata/tls | 1 + 2 files changed, 17 insertions(+) create mode 100644 std/http/testdata/simple_https_server.ts create mode 120000 std/http/testdata/tls (limited to 'std/http/testdata') diff --git a/std/http/testdata/simple_https_server.ts b/std/http/testdata/simple_https_server.ts new file mode 100644 index 000000000..655457c94 --- /dev/null +++ b/std/http/testdata/simple_https_server.ts @@ -0,0 +1,16 @@ +// Copyright 2018-2019 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: "./http/testdata/tls/localhost.crt", + keyFile: "./http/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 }); +} diff --git a/std/http/testdata/tls b/std/http/testdata/tls new file mode 120000 index 000000000..f6fd22ed8 --- /dev/null +++ b/std/http/testdata/tls @@ -0,0 +1 @@ +../../../cli/tests/tls \ No newline at end of file -- cgit v1.2.3