Skip to content

Commit da674ec

Browse files
ArGGujcrugzz
authored andcommitted
Modify the set-cookie header fix to work with node 0.10.x.
1 parent 855cebd commit da674ec

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

lib/http-proxy/passes/ws-incoming.js

+19-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var http = require('http'),
22
https = require('https'),
3+
util = require('util'),
34
common = require('../common'),
45
passes = exports;
56

@@ -113,12 +114,24 @@ var passes = exports;
113114

114115
if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead);
115116

116-
socket.write('HTTP/1.1 101 Switching Protocols\r\n');
117-
socket.write(proxyRes.rawHeaders.map(function(v, i, a) {
118-
return !(i % 2) ? v + ": " + a[i+1] : null;
119-
}).filter(function (v) {
120-
return v ? true : false;
121-
}).join('\r\n') + '\r\n\r\n');
117+
var writeHead = [
118+
'HTTP/1.1 101 Switching Protocols'
119+
];
120+
121+
Object.keys(proxyRes.headers).map(function(i) {
122+
if (util.isArray(proxyRes.headers[i])) {
123+
var a = proxyRes.headers[i];
124+
var len = a.length;
125+
126+
for (var x = 0; x < len; x++) {
127+
writeHead.push(i + ": " + a[x]);
128+
}
129+
} else {
130+
writeHead.push(i + ": " + proxyRes.headers[i]);
131+
}
132+
});
133+
134+
socket.write(writeHead.join('\r\n') + '\r\n\r\n');
122135
proxySocket.pipe(socket).pipe(proxySocket);
123136

124137
server.emit('open', proxySocket);

0 commit comments

Comments
 (0)