Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion doc/api/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ An [`Agent`][] object for HTTPS similar to [`http.Agent`][]. See
* `options` {Object} Set of configurable options to set on the agent.
Can have the same fields as for [`http.Agent(options)`][], and
* `maxCachedSessions` {number} maximum number of TLS cached sessions.
Use `0` to disable TLS session caching. **Default:** `100`.
Use `0` to disable TLS session caching. **Default:** `100`
Comment thread
indutny marked this conversation as resolved.
Outdated
* `servername` {string | boolean} the value of
[Server Name Indication extension](https://en.wikipedia.org/wiki/Server_Name_Indication)
to be sent to the server. Use `false` to disable sending the extension.
**Default:** hostname or ip address of the target server
Comment thread
indutny marked this conversation as resolved.
Outdated

See [`Session Resumption`][] for infomation about TLS session reuse.

Expand Down
4 changes: 2 additions & 2 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
if (options.socketPath)
options.path = options.socketPath;

if (!options.servername)
if (!options.servername && options.servername !== false)
options.servername = calculateServerName(options, req);

const name = this.getName(options);
Expand Down Expand Up @@ -198,7 +198,7 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) {
if (options.socketPath)
options.path = options.socketPath;

if (!options.servername)
if (!options.servername && options.servername !== false)
options.servername = calculateServerName(options, req);

const name = this.getName(options);
Expand Down
21 changes: 17 additions & 4 deletions test/parallel/test-https-agent-sni.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ let waiting = TOTAL;
const server = https.Server(options, function(req, res) {
if (--waiting === 0) server.close();

res.writeHead(200, {
'x-sni': req.socket.servername
});
const servername = req.socket.servername;

if (servername !== false) {
res.setHeader('x-sni', servername);
}

res.end('hello world');
});

server.listen(0, function() {
function expectResponse(id) {
return common.mustCall(function(res) {
res.resume();
assert.strictEqual(res.headers['x-sni'], `sni.${id}`);
assert.strictEqual(res.headers['x-sni'],
id === false ? undefined : `sni.${id}`);
Comment thread
indutny marked this conversation as resolved.
Outdated
});
}

Expand All @@ -46,4 +50,13 @@ server.listen(0, function() {
rejectUnauthorized: false
}, expectResponse(j));
}
https.get({
agent: agent,

Comment thread
indutny marked this conversation as resolved.
Outdated
path: '/',
port: this.address().port,
host: '127.0.0.1',
servername: false,
rejectUnauthorized: false
}, expectResponse(false));
});