Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
[squash] the nits
  • Loading branch information
bengl committed Sep 23, 2017
commit 2da5453d42d183259b79c75dedbc18aedd2f8d41
2 changes: 1 addition & 1 deletion lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function ClientRequest(options, cb) {
this._last = true;
this.shouldKeepAlive = false;
if (typeof options.createConnection === 'function') {
var newSocket = options.createConnection(options, oncreate);
const newSocket = options.createConnection(options, oncreate);
if (newSocket && !called) {
called = true;
this.onSocket(newSocket);
Expand Down
12 changes: 11 additions & 1 deletion test/parallel/test-http-agent-getname.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
'use strict';

require('../common');
const common = require('../common');
const assert = require('assert');
const http = require('http');
const path = require('path');

const agent = new http.Agent();

Expand Down Expand Up @@ -31,6 +32,15 @@ assert.strictEqual(
'0.0.0.0:80:192.168.1.1'
);

// unix socket
const socketPath = path.join(common.tmpDir, 'foo', 'bar');
assert.strictEqual(
agent.getName({
socketPath
}),
`localhost:::${socketPath}`
);

for (const family of [0, null, undefined, 'bogus'])
assert.strictEqual(agent.getName({ family }), 'localhost::');

Expand Down
17 changes: 10 additions & 7 deletions test/parallel/test-http-unix-socket-keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ const server = http.createServer((req, res) => res.end());

common.refreshTmpDir();

server.listen(common.PIPE, () =>
asyncLoop(makeKeepAliveRequest, 10, () =>
server.listen(common.PIPE, common.mustCall(() =>
asyncLoop(makeKeepAliveRequest, 10, common.mustCall(() =>
server.getConnections(common.mustCall((err, conns) => {
assert.ifError(err);
assert.strictEqual(1, conns);
assert.strictEqual(conns, 1);
server.close();
}))
)
);
))
));

function asyncLoop(fn, times, cb) {
fn(function handler() {
Expand All @@ -29,6 +29,9 @@ function asyncLoop(fn, times, cb) {
function makeKeepAliveRequest(cb) {
http.get({
socketPath: common.PIPE,
headers: {connection: 'keep-alive'}
}, (res) => res.on('data', () => {}).on('error', assert.fail).on('end', cb));
headers: { connection: 'keep-alive' }
}, (res) => res.on('data', common.mustNotCall())
.on('error', assert.fail)
.on('end', cb)
);
}