From c50524a9fc19cd2fe6e61bb7f8ad22685024842b Mon Sep 17 00:00:00 2001 From: snek Date: Fri, 12 Jan 2024 08:09:48 -0800 Subject: [PATCH] http2: add server handshake utility PR-URL: https://github.com/nodejs/node/pull/51172 Reviewed-By: Matteo Collina --- doc/api/http2.md | 13 +++++ lib/http2.js | 2 + lib/internal/http2/core.js | 20 +++++--- lib/internal/js_stream_socket.js | 9 ++++ .../test-http2-perform-server-handshake.js | 48 +++++++++++++++++++ 5 files changed, 85 insertions(+), 7 deletions(-) create mode 100644 test/parallel/test-http2-perform-server-handshake.js diff --git a/doc/api/http2.md b/doc/api/http2.md index 8b3ce0aad24d3f..0b91e2b36aa267 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -2890,6 +2890,19 @@ added: v8.4.0 Returns a [HTTP/2 Settings Object][] containing the deserialized settings from the given `Buffer` as generated by `http2.getPackedSettings()`. +### `http2.performServerHandshake(socket[, options])` + + + +* `socket` {stream.Duplex} +* `options` {Object} + * ...: Any [`http2.createServer()`][] option can be provided. +* Returns: {ServerHttp2Session} + +Create an HTTP/2 server session from an existing socket. + ### `http2.sensitiveHeaders`