Skip to content

Commit 3c930d2

Browse files
bobniladuh95
authored andcommitted
doc: document this binding in TLS callbacks
Document that `this` is bound to the `tls.TLSSocket` instance when `SNICallback` and `ALPNCallback` are invoked. Signed-off-by: Robert I Nilsson <robert.i.nilsson@callclue.com> PR-URL: #66682 Reviewed-By: Tim Perry <pimterry@gmail.com>
1 parent a92ee33 commit 3c930d2

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎doc/api/tls.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,8 @@ changes:
22522252
e.g. `0x05hello0x05world`, where the first byte is the length of the next
22532253
protocol name. Passing an array is usually much simpler, e.g.
22542254
`['hello', 'world']`. (Protocols should be ordered by their priority.)
2255-
* `ALPNCallback` {Function} If set, this will be called when a
2255+
* `ALPNCallback` {Function} If set, this will be called
2256+
(with `this` set to the `tls.TLSSocket` instance) when a
22562257
client opens a connection using the ALPN extension. One argument will
22572258
be passed to the callback: an object containing `servername` and
22582259
`protocols` fields, respectively containing the server name from
@@ -2282,7 +2283,8 @@ changes:
22822283
[Session Resumption][] for more information. **Default:** `300`.
22832284
* `SNICallback(servername, callback)` {Function} A function that will be
22842285
called if the client supports SNI TLS extension. Two arguments will be
2285-
passed when called: `servername` and `callback`. `callback` is an
2286+
passed when called: `servername` and `callback`, with `this` set to the
2287+
`tls.TLSSocket` instance associated with the connection. `callback` is an
22862288
error-first callback that takes two optional arguments: `error` and `ctx`.
22872289
`ctx`, if provided, is a `SecureContext` instance.
22882290
[`tls.createSecureContext()`][] can be used to get a proper `SecureContext`.

0 commit comments

Comments
 (0)