Skip to content

Commit

Permalink
http: fix agent.getName() and add tests
Browse files Browse the repository at this point in the history
This commit fixes agent.getName(), which returned an extra colon
according to the docs, and adds tests (it was previously not unit
tested).
  • Loading branch information
brendanashworth committed Jul 31, 2015
1 parent 115bf08 commit f0de101
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ Agent.prototype.getName = function(options) {
name += ':';
if (options.localAddress)
name += options.localAddress;
name += ':';
return name;
};

Expand Down
32 changes: 32 additions & 0 deletions test/parallel/test-http-agent-getname.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';

var assert = require('assert');
var http = require('http');
var common = require('../common');

var agent = new http.Agent();

// default to localhost
assert.equal(
agent.getName({
port: 80,
localAddress: '192.168.1.1'
}),
'localhost:80:192.168.1.1'
);

// empty
assert.equal(
agent.getName({}),
'localhost::'
);

// pass all arguments
assert.equal(
agent.getName({
host: '0.0.0.0',
port: 80,
localAddress: '192.168.1.1'
}),
'0.0.0.0:80:192.168.1.1'
);
2 changes: 1 addition & 1 deletion test/parallel/test-http-agent-keepalive.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function get(path, callback) {
}, callback);
}

var name = 'localhost:' + common.PORT + '::';
var name = 'localhost:' + common.PORT + ':';

function checkDataAndSockets(body) {
assert.equal(body.toString(), 'hello world');
Expand Down

0 comments on commit f0de101

Please sign in to comment.