Skip to content

Commit

Permalink
[fix] write connection header
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Sep 17, 2013
1 parent 031452e commit 2c10f25
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/caronte/passes/web-incoming.js
Expand Up @@ -121,7 +121,7 @@ function stream(req, res, options) {
var evnt = ev + pass.name.toLowerCase() + ':';

options.ee.emit(evnt + 'begin', req, res);
var val = pass(res, proxyRes);
var val = pass(req, res, proxyRes);
options.ee.emit(evnt + 'end');

return val;
Expand Down
21 changes: 18 additions & 3 deletions lib/caronte/passes/web-outgoing.js
Expand Up @@ -9,14 +9,29 @@ var passes = exports;
*/

[ // <--

function writeHeaders(res, proxyRes) {

function setConnection(req, res, proxyRes) {
if (req.httpVersion === '1.0') {
if (req.headers.connection) {
proxyRes.headers.connection = req.headers.connection
} else {
proxyRes.headers.connection = 'close'
}
} else if (!proxyRes.headers.connection) {
if (req.headers.connection) { proxyRes.headers.connection = req.headers.connection }
else {
proxyRes.headers.connection = 'keep-alive'
}
}
},

function writeHeaders(req, res, proxyRes) {
Object.keys(proxyRes.headers).forEach(function(key) {
res.setHeader(key, proxyRes.headers[key]);
});
},

function writeStatusCode(res, proxyRes) {
function writeStatusCode(req, res, proxyRes) {
res.writeHead(proxyRes.statusCode);
}

Expand Down

0 comments on commit 2c10f25

Please sign in to comment.