mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(ext/node): pass alpnProtocols to Deno.startTls (#22512)
This commit is contained in:
parent
c75c9a0727
commit
061ee9d38c
3 changed files with 38 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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<void>();
|
||||
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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue