Philipp Partosch 46a936d7de added all files to project | 2 years ago | |
---|---|---|
.. | ||
LICENSE | 2 years ago | |
README.md | 2 years ago | |
index.js | 2 years ago | |
package.json | 2 years ago |
resolve-alpn
Returns an object with an alpnProtocol
property. The socket
property may be also present.
const result = await resolveALPN({
host: 'nghttp2.org',
port: 443,
ALPNProtocols: ['h2', 'http/1.1'],
servername: 'nghttp2.org'
});
console.log(result); // {alpnProtocol: 'h2'}
Note: While the servername
option is not required in this case, many other servers do. It’s best practice to set it anyway.
Note: If the socket times out, the promise will resolve and result.timeout
will be set to true
.
Same as TLS options.
By default, the socket gets destroyed and the promise resolves.
If you set this to true, it will return the socket in a socket
property.
const result = await resolveALPN({
host: 'nghttp2.org',
port: 443,
ALPNProtocols: ['h2', 'http/1.1'],
servername: 'nghttp2.org',
resolveSocket: true
});
console.log(result); // {alpnProtocol: 'h2', socket: tls.TLSSocket}
// Remember to destroy the socket if you don't use it!
result.socket.destroy();
MIT