Skip to content

Commit

Permalink
[api test] All tests are passing when run as individual files
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Mar 9, 2011
1 parent e39a9f9 commit 389159d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 6 additions & 1 deletion lib/node-http-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ exports.createServer = function () {
server.on('close', function () {
proxy.close();
});

proxy.on('routes', function (routes) {
server.emit('routes', routes);
})

if (!callback) {
// WebSocket support: if callback is empty tunnel
Expand Down Expand Up @@ -180,11 +184,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, paused) {
// always ignore the proxyTable if an explicit `port` and `host`
// arguments are supplied to `proxyRequest`.
//

if (this.proxyTable && !host) {
location = this.proxyTable.getProxyLocation(req);

if (!location) {
res.writeHead(400);
res.writeHead(404);
return res.end();
}

Expand Down
13 changes: 8 additions & 5 deletions test/proxy-table-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ vows.describe('node-http-proxy/proxy-table').addBatch({
}
};

runner.startTargetServer(8103, that.output);
request(options, that.callback);
runner.startTargetServer(8103, that.output, function () {
request(options, that.callback);
});
});
},
"should receive 'hello dynamic.com'": function (err, res, body) {
Expand All @@ -88,8 +89,10 @@ vows.describe('node-http-proxy/proxy-table').addBatch({
"When using an instance of ProxyTable combined with HttpProxy directly": {
topic: function () {
this.server = runner.startProxyServerWithTableAndLatency(8110, 100, {
'foo.com': 'localhost:8111',
'bar.com': 'localhost:8112'
router: {
'foo.com': 'localhost:8111',
'bar.com': 'localhost:8112'
}
}, this.callback);
},
"an incoming request to foo.com": assertProxiedWithTarget(runner, 'foo.com', 8110, 8111),
Expand All @@ -99,7 +102,7 @@ vows.describe('node-http-proxy/proxy-table').addBatch({
}).addBatch({
"When the tests are over": {
topic: function () {
fs.unlinkSync(routeFile);
//fs.unlinkSync(routeFile);
return runner.closeServers();
},
"the servers should clean up": function () {
Expand Down

0 comments on commit 389159d

Please sign in to comment.