Skip to content

Commit

Permalink
[squash] the nits
Browse files Browse the repository at this point in the history
  • Loading branch information
bengl committed Sep 23, 2017
1 parent d93aa85 commit 2da5453
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
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)
);
}

0 comments on commit 2da5453

Please sign in to comment.