summaryrefslogtreecommitdiff
path: root/tests/unit_node/http_test.ts
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2024-04-18 09:37:47 -0600
committerGitHub <noreply@github.com>2024-04-18 09:37:47 -0600
commit5e2a747685490b31efa778241fccf938bd33722d (patch)
tree6ede300e32bf57942ba0bf4ddae8d4eb02026e5a /tests/unit_node/http_test.ts
parent25a80bc523bf47d5eba8d578b9ffeba26a8d0341 (diff)
fix(ext/node): Correctly send ALPN on node TLS connections (#23434)
Landing work from #21903, plus fixing a node compat bug. We were always sending the HTTP/2 ALPN on TLS connections which might confuse upstream servers. Changes: - Configure HTTP/2 ALPN when making the TLS connection from the HTTP/2 code - Read the `ALPNProtocols` property from the TLS connection options rather than the deno `alpnProtocols` field - Add tests Prereq for landing Deno.serveHttp on Deno.serve: removing older HTTP servers from the codebase.
Diffstat (limited to 'tests/unit_node/http_test.ts')
-rw-r--r--tests/unit_node/http_test.ts19
1 files changed, 6 insertions, 13 deletions
diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts
index 049cdbbbc..6672b9747 100644
--- a/tests/unit_node/http_test.ts
+++ b/tests/unit_node/http_test.ts
@@ -9,7 +9,6 @@ import { assertSpyCalls, spy } from "@std/testing/mock.ts";
import { gzip } from "node:zlib";
import { Buffer } from "node:buffer";
-import { serve } from "@std/http/server.ts";
import { execCode } from "../unit/test_util.ts";
Deno.test("[node/http listen]", async () => {
@@ -338,20 +337,18 @@ Deno.test("[node/http] send request with non-chunked body", async () => {
const hostname = "localhost";
const port = 4505;
- // NOTE: Instead of node/http.createServer(), serve() in std/http/server.ts is used.
- // https://github.com/denoland/deno_std/pull/2755#discussion_r1005592634
const handler = async (req: Request) => {
requestHeaders = req.headers;
requestBody = await req.text();
return new Response("ok");
};
const abortController = new AbortController();
- const servePromise = serve(handler, {
+ const servePromise = Deno.serve({
hostname,
port,
signal: abortController.signal,
onListen: undefined,
- });
+ }, handler).finished;
const opts: RequestOptions = {
host: hostname,
@@ -393,20 +390,18 @@ Deno.test("[node/http] send request with chunked body", async () => {
const hostname = "localhost";
const port = 4505;
- // NOTE: Instead of node/http.createServer(), serve() in std/http/server.ts is used.
- // https://github.com/denoland/deno_std/pull/2755#discussion_r1005592634
const handler = async (req: Request) => {
requestHeaders = req.headers;
requestBody = await req.text();
return new Response("ok");
};
const abortController = new AbortController();
- const servePromise = serve(handler, {
+ const servePromise = Deno.serve({
hostname,
port,
signal: abortController.signal,
onListen: undefined,
- });
+ }, handler).finished;
const opts: RequestOptions = {
host: hostname,
@@ -442,20 +437,18 @@ Deno.test("[node/http] send request with chunked body as default", async () => {
const hostname = "localhost";
const port = 4505;
- // NOTE: Instead of node/http.createServer(), serve() in std/http/server.ts is used.
- // https://github.com/denoland/deno_std/pull/2755#discussion_r1005592634
const handler = async (req: Request) => {
requestHeaders = req.headers;
requestBody = await req.text();
return new Response("ok");
};
const abortController = new AbortController();
- const servePromise = serve(handler, {
+ const servePromise = Deno.serve({
hostname,
port,
signal: abortController.signal,
onListen: undefined,
- });
+ }, handler).finished;
const opts: RequestOptions = {
host: hostname,