Commit 6d08f24c authored by indexzero's avatar indexzero

[api minor debug] Remove debug code, set Connection header if not set

parent 9715ebd4
...@@ -81,6 +81,7 @@ var createProxy = function () { ...@@ -81,6 +81,7 @@ var createProxy = function () {
server.emit('route', req, res, function (port, hostname) { server.emit('route', req, res, function (port, hostname) {
var p = manager.getPool(port, hostname); var p = manager.getPool(port, hostname);
req.headers.Connection = req.headers.Connection || 'close';
p.request(req.method, req.url, req.headers, function (reverse_proxy) { p.request(req.method, req.url, req.headers, function (reverse_proxy) {
var data = ''; var data = '';
reverse_proxy.on('error', function (err) { reverse_proxy.on('error', function (err) {
...@@ -103,12 +104,8 @@ var createProxy = function () { ...@@ -103,12 +104,8 @@ var createProxy = function () {
sys.pump(req, reverse_proxy); sys.pump(req, reverse_proxy);
if (e) { if (e) {
sys.puts('end outgoing request');
req.removeListener('end', e); req.removeListener('end', e);
req.addListener('end', function () { req.addListener('end', function () { reverse_proxy.end() });
sys.puts('request ended');
reverse_proxy.end()
});
} }
else { else {
reverse_proxy.end(); reverse_proxy.end();
...@@ -125,10 +122,10 @@ var createProxy = function () { ...@@ -125,10 +122,10 @@ var createProxy = function () {
response.addListener('end', function() { response.addListener('end', function() {
server.emit('proxy', null, data); server.emit('proxy', null, data);
}); });
sys.puts('response');
// Set the response headers of the client response // Set the response headers of the client response
res.writeHead(response.statusCode, response.headers); res.writeHead(response.statusCode, response.headers);
sys.pump(response, res); sys.pump(response, res);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment