mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: fix agent.getName() and add tests
This commit fixes agent.getName(), which returned an extra colon according to the docs, and adds tests (it was previously not unit tested). PR-URL: https://github.com/nodejs/io.js/pull/1617 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
committed by
Rod Vagg
parent
4cffaa3f55
commit
2965442308
@@ -107,7 +107,6 @@ Agent.prototype.getName = function(options) {
|
||||
name += ':';
|
||||
if (options.localAddress)
|
||||
name += options.localAddress;
|
||||
name += ':';
|
||||
return name;
|
||||
};
|
||||
|
||||
|
||||
32
test/parallel/test-http-agent-getname.js
Normal file
32
test/parallel/test-http-agent-getname.js
Normal file
@@ -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'
|
||||
);
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user