Skip to content

Commit 2c10f25

Browse files
committed
[fix] write connection header
1 parent 031452e commit 2c10f25

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

Diff for: lib/caronte/passes/web-incoming.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ function stream(req, res, options) {
121121
var evnt = ev + pass.name.toLowerCase() + ':';
122122

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

127127
return val;

Diff for: lib/caronte/passes/web-outgoing.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,29 @@ var passes = exports;
99
*/
1010

1111
[ // <--
12-
13-
function writeHeaders(res, proxyRes) {
12+
13+
function setConnection(req, res, proxyRes) {
14+
if (req.httpVersion === '1.0') {
15+
if (req.headers.connection) {
16+
proxyRes.headers.connection = req.headers.connection
17+
} else {
18+
proxyRes.headers.connection = 'close'
19+
}
20+
} else if (!proxyRes.headers.connection) {
21+
if (req.headers.connection) { proxyRes.headers.connection = req.headers.connection }
22+
else {
23+
proxyRes.headers.connection = 'keep-alive'
24+
}
25+
}
26+
},
27+
28+
function writeHeaders(req, res, proxyRes) {
1429
Object.keys(proxyRes.headers).forEach(function(key) {
1530
res.setHeader(key, proxyRes.headers[key]);
1631
});
1732
},
1833

19-
function writeStatusCode(res, proxyRes) {
34+
function writeStatusCode(req, res, proxyRes) {
2035
res.writeHead(proxyRes.statusCode);
2136
}
2237

0 commit comments

Comments
 (0)