aboutsummaryrefslogtreecommitdiff
path: root/node_modules/resolve-alpn/README.md
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2022-02-09 17:58:07 +0100
committerMinteck <contact@minteck.org>2022-02-09 17:58:07 +0100
commit22a25ded9f7d9c9a96cce8d1bc12475ca0434201 (patch)
tree0e33d0650fe58f41c00bbc4b8047956905766823 /node_modules/resolve-alpn/README.md
parent8f54d903fb3470823a5e4d6ff4655de009836245 (diff)
downloadyoutoo-22a25ded9f7d9c9a96cce8d1bc12475ca0434201.tar.gz
youtoo-22a25ded9f7d9c9a96cce8d1bc12475ca0434201.tar.bz2
youtoo-22a25ded9f7d9c9a96cce8d1bc12475ca0434201.zip
Major update
Diffstat (limited to 'node_modules/resolve-alpn/README.md')
-rw-r--r--node_modules/resolve-alpn/README.md60
1 files changed, 60 insertions, 0 deletions
diff --git a/node_modules/resolve-alpn/README.md b/node_modules/resolve-alpn/README.md
new file mode 100644
index 0000000..a49950c
--- /dev/null
+++ b/node_modules/resolve-alpn/README.md
@@ -0,0 +1,60 @@
+# `resolve-alpn`
+
+[![Node CI](https://github.com/szmarczak/resolve-alpn/workflows/Node%20CI/badge.svg)](https://github.com/szmarczak/resolve-alpn/actions)
+[![codecov](https://codecov.io/gh/szmarczak/resolve-alpn/branch/master/graph/badge.svg)](https://codecov.io/gh/szmarczak/resolve-alpn)
+
+## API
+
+### resolveALPN(options, connect = tls.connect)
+
+Returns an object with an `alpnProtocol` property. The `socket` property may be also present.
+
+```js
+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`.
+
+#### options
+
+Same as [TLS options](https://nodejs.org/api/tls.html#tls_tls_connect_options_callback).
+
+##### options.resolveSocket
+
+By default, the socket gets destroyed and the promise resolves.<br>
+If you set this to true, it will return the socket in a `socket` property.
+
+```js
+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();
+```
+
+#### connect
+
+Type: `Function<TLSSocket> | AsyncFunction<TLSSocket>`\
+Default: [`tls.connect`](https://nodejs.org/dist/latest-v16.x/docs/api/tls.html#tls_tls_connect_options_callback)
+
+**Note:** No matter which function is used (synchronous or asynchronous), it **must** accept a `callback` function as a second argument. The `callback` function gets executed when the socket has successfully connected.
+
+## License
+
+MIT