diff --git a/ext/node/polyfills/_tls_wrap.ts b/ext/node/polyfills/_tls_wrap.ts index 315cbf74ab..a70dd29f14 100644 --- a/ext/node/polyfills/_tls_wrap.ts +++ b/ext/node/polyfills/_tls_wrap.ts @@ -68,7 +68,7 @@ export class TLSSocket extends net.Socket { secureConnecting: boolean; _SNICallback: any; servername: string | null; - alpnProtocol: any; + alpnProtocols: string[] | null; authorized: boolean; authorizationError: any; [kRes]: any; @@ -96,6 +96,7 @@ export class TLSSocket extends net.Socket { caCerts = [new TextDecoder().decode(caCerts)]; } tlsOptions.caCerts = caCerts; + tlsOptions.alpnProtocols = ["h2", "http/1.1"]; super({ handle: _wrapHandle(tlsOptions, socket), @@ -113,7 +114,7 @@ export class TLSSocket extends net.Socket { this.secureConnecting = true; this._SNICallback = null; this.servername = null; - this.alpnProtocol = null; + this.alpnProtocols = tlsOptions.alpnProtocols; this.authorized = false; this.authorizationError = null; this[kRes] = null; diff --git a/ext/node/polyfills/http2.ts b/ext/node/polyfills/http2.ts index a13953e760..d86148e4e2 100644 --- a/ext/node/polyfills/http2.ts +++ b/ext/node/polyfills/http2.ts @@ -210,11 +210,12 @@ export class Http2Session extends EventEmitter { } goaway( - _code: number, - _lastStreamID: number, - _opaqueData: Buffer | TypedArray | DataView, + code?: number, + lastStreamID?: number, + opaqueData?: Buffer | TypedArray | DataView, ) { - warnNotImplemented("Http2Session.goaway"); + // TODO(satyarohith): create goaway op and pass the args + debugHttp2(">>> goaway - ignored args", code, lastStreamID, opaqueData); if (this[kDenoConnRid]) { core.tryClose(this[kDenoConnRid]); } diff --git a/tests/unit_node/http2_test.ts b/tests/unit_node/http2_test.ts index 2ea2924853..fd9cdd0ec8 100644 --- a/tests/unit_node/http2_test.ts +++ b/tests/unit_node/http2_test.ts @@ -2,7 +2,7 @@ import * as http2 from "node:http2"; import * as net from "node:net"; -import { assertEquals } from "@std/assert/mod.ts"; +import { assert, assertEquals } from "@std/assert/mod.ts"; for (const url of ["http://127.0.0.1:4246", "https://127.0.0.1:4247"]) { Deno.test(`[node/http2 client] ${url}`, { @@ -136,3 +136,32 @@ Deno.test("[node/http2 server]", { sanitizeOps: false }, async () => { await new Promise((resolve) => server.close(resolve)); }); + +Deno.test("[node/http2 client GET https://www.example.com]", async () => { + const clientSession = http2.connect("https://www.example.com"); + const req = clientSession.request({ + ":method": "GET", + ":path": "/", + }); + let headers = {}; + let status: number | undefined = 0; + let chunk = new Uint8Array(); + const endPromise = Promise.withResolvers(); + req.on("response", (h) => { + status = h[":status"]; + headers = h; + }); + req.on("data", (c) => { + chunk = c; + }); + req.on("end", () => { + clientSession.close(); + req.close(); + endPromise.resolve(); + }); + req.end(); + await endPromise.promise; + assert(Object.keys(headers).length > 0); + assertEquals(status, 200); + assert(chunk.length > 0); +});