[api] Integrated a little more from Mikeal to make our return headers consistent

This commit is contained in:
indexzero 2010-09-07 16:15:04 -04:00
parent 6d08f24c86
commit eb39018fd0

View File

@ -81,7 +81,6 @@ 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) {
@ -113,6 +112,11 @@ var createProxy = function () {
// Add a listener for the reverse_proxy response event // Add a listener for the reverse_proxy response event
reverse_proxy.addListener('response', function (response) { reverse_proxy.addListener('response', function (response) {
if (response.headers.connection) {
if (req.headers.connection) response.headers.connection = req.headers.connection;
else response.headers.connection = 'close';
}
// These two listeners are for testability and observation // These two listeners are for testability and observation
// of what's passed back from the target server // of what's passed back from the target server
response.addListener('data', function (chunk) { response.addListener('data', function (chunk) {