From 2da5453d42d183259b79c75dedbc18aedd2f8d41 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 1 Jun 2017 23:36:11 -0700 Subject: [PATCH] [squash] the nits --- lib/_http_client.js | 2 +- test/parallel/test-http-agent-getname.js | 12 +++++++++++- .../test-http-unix-socket-keep-alive.js | 17 ++++++++++------- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index 36e4210019fec1..6eb7d34fc57dcb 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -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); diff --git a/test/parallel/test-http-agent-getname.js b/test/parallel/test-http-agent-getname.js index f84996ec013eec..4b4e9ac26b44a5 100644 --- a/test/parallel/test-http-agent-getname.js +++ b/test/parallel/test-http-agent-getname.js @@ -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(); @@ -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::'); diff --git a/test/parallel/test-http-unix-socket-keep-alive.js b/test/parallel/test-http-unix-socket-keep-alive.js index 33c65a88f19903..668c440325e0ec 100644 --- a/test/parallel/test-http-unix-socket-keep-alive.js +++ b/test/parallel/test-http-unix-socket-keep-alive.js @@ -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() { @@ -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) + ); }