package node; @:jsRequire("node:http2") @valueModuleOnly extern class NodeHttp2 { /** Returns an object containing the default settings for an `Http2Session`instance. This method returns a new object instance every time it is called so instances returned may be safely modified for use. **/ static function getDefaultSettings():node.http2.Settings; /** Returns a `Buffer` instance containing serialized representation of the given HTTP/2 settings as specified in the [HTTP/2](https://tools.ietf.org/html/rfc7540) specification. This is intended for use with the `HTTP2-Settings` header field. ```js const http2 = require('node:http2'); const packed = http2.getPackedSettings({ enablePush: false }); console.log(packed.toString('base64')); // Prints: AAIAAAAA ``` **/ static function getPackedSettings(settings:node.http2.Settings):node.buffer.Buffer; /** Returns a `HTTP/2 Settings Object` containing the deserialized settings from the given `Buffer` as generated by `http2.getPackedSettings()`. **/ static function getUnpackedSettings(buf:js.lib.Uint8Array):node.http2.Settings; /** Returns a `net.Server` instance that creates and manages `Http2Session`instances. Since there are no browsers known that support [unencrypted HTTP/2](https://http2.github.io/faq/#does-http2-require-encryption), the use of {@link createSecureServer} is necessary when communicating with browser clients. ```js const http2 = require('node:http2'); // Create an unencrypted HTTP/2 server. // Since there are no browsers known that support // unencrypted HTTP/2, the use of `http2.createSecureServer()` // is necessary when communicating with browser clients. const server = http2.createServer(); server.on('stream', (stream, headers) => { stream.respond({ 'content-type': 'text/html; charset=utf-8', ':status': 200, }); stream.end('

Hello World

'); }); server.listen(8000); ``` **/ @:overload(function(options:node.http2.ServerOptions, ?onRequestHandler:(request:node.http2.Http2ServerRequest, response:node.http2.Http2ServerResponse) -> Void):node.http2.Http2Server { }) static function createServer(?onRequestHandler:(request:node.http2.Http2ServerRequest, response:node.http2.Http2ServerResponse) -> Void):node.http2.Http2Server; /** Returns a `tls.Server` instance that creates and manages `Http2Session`instances. ```js const http2 = require('node:http2'); const fs = require('node:fs'); const options = { key: fs.readFileSync('server-key.pem'), cert: fs.readFileSync('server-cert.pem'), }; // Create a secure HTTP/2 server const server = http2.createSecureServer(options); server.on('stream', (stream, headers) => { stream.respond({ 'content-type': 'text/html; charset=utf-8', ':status': 200, }); stream.end('

Hello World

'); }); server.listen(8443); ``` **/ @:overload(function(options:node.http2.SecureServerOptions, ?onRequestHandler:(request:node.http2.Http2ServerRequest, response:node.http2.Http2ServerResponse) -> Void):node.http2.Http2SecureServer { }) static function createSecureServer(?onRequestHandler:(request:node.http2.Http2ServerRequest, response:node.http2.Http2ServerResponse) -> Void):node.http2.Http2SecureServer; /** Returns a `ClientHttp2Session` instance. ```js const http2 = require('node:http2'); const client = http2.connect('https://localhost:1234'); // Use the client client.close(); ``` **/ @:overload(function(authority:ts.AnyOf2, ?options:ts.AnyOf2, ?listener:(session:node.http2.ClientHttp2Session, socket:ts.AnyOf2) -> Void):node.http2.ClientHttp2Session { }) static function connect(authority:ts.AnyOf2, listener:(session:node.http2.ClientHttp2Session, socket:ts.AnyOf2) -> Void):node.http2.ClientHttp2Session; /** This symbol can be set as a property on the HTTP/2 headers object with an array value in order to provide a list of headers considered sensitive. **/ static final sensitiveHeaders : js.lib.Symbol; }