Skip to content

Commit 389159d

Browse files
committed
[api test] All tests are passing when run as individual files
1 parent e39a9f9 commit 389159d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

Diff for: lib/node-http-proxy.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ exports.createServer = function () {
9595
server.on('close', function () {
9696
proxy.close();
9797
});
98+
99+
proxy.on('routes', function (routes) {
100+
server.emit('routes', routes);
101+
})
98102

99103
if (!callback) {
100104
// WebSocket support: if callback is empty tunnel
@@ -180,11 +184,12 @@ HttpProxy.prototype.proxyRequest = function (req, res, port, host, paused) {
180184
// always ignore the proxyTable if an explicit `port` and `host`
181185
// arguments are supplied to `proxyRequest`.
182186
//
187+
183188
if (this.proxyTable && !host) {
184189
location = this.proxyTable.getProxyLocation(req);
185190

186191
if (!location) {
187-
res.writeHead(400);
192+
res.writeHead(404);
188193
return res.end();
189194
}
190195

Diff for: test/proxy-table-test.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ vows.describe('node-http-proxy/proxy-table').addBatch({
7373
}
7474
};
7575

76-
runner.startTargetServer(8103, that.output);
77-
request(options, that.callback);
76+
runner.startTargetServer(8103, that.output, function () {
77+
request(options, that.callback);
78+
});
7879
});
7980
},
8081
"should receive 'hello dynamic.com'": function (err, res, body) {
@@ -88,8 +89,10 @@ vows.describe('node-http-proxy/proxy-table').addBatch({
8889
"When using an instance of ProxyTable combined with HttpProxy directly": {
8990
topic: function () {
9091
this.server = runner.startProxyServerWithTableAndLatency(8110, 100, {
91-
'foo.com': 'localhost:8111',
92-
'bar.com': 'localhost:8112'
92+
router: {
93+
'foo.com': 'localhost:8111',
94+
'bar.com': 'localhost:8112'
95+
}
9396
}, this.callback);
9497
},
9598
"an incoming request to foo.com": assertProxiedWithTarget(runner, 'foo.com', 8110, 8111),
@@ -99,7 +102,7 @@ vows.describe('node-http-proxy/proxy-table').addBatch({
99102
}).addBatch({
100103
"When the tests are over": {
101104
topic: function () {
102-
fs.unlinkSync(routeFile);
105+
//fs.unlinkSync(routeFile);
103106
return runner.closeServers();
104107
},
105108
"the servers should clean up": function () {

0 commit comments

Comments
 (0)