Modify the set-cookie header fix to work with node 0.10.x.

This commit is contained in:
Arttu Liimola 2015-08-30 22:17:18 +03:00 committed by Jarrett Cruger
parent 855cebdac4
commit da674ec4df

View File

@ -1,5 +1,6 @@
var http = require('http'),
https = require('https'),
util = require('util'),
common = require('../common'),
passes = exports;
@ -113,12 +114,24 @@ var passes = exports;
if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead);
socket.write('HTTP/1.1 101 Switching Protocols\r\n');
socket.write(proxyRes.rawHeaders.map(function(v, i, a) {
return !(i % 2) ? v + ": " + a[i+1] : null;
}).filter(function (v) {
return v ? true : false;
}).join('\r\n') + '\r\n\r\n');
var writeHead = [
'HTTP/1.1 101 Switching Protocols'
];
Object.keys(proxyRes.headers).map(function(i) {
if (util.isArray(proxyRes.headers[i])) {
var a = proxyRes.headers[i];
var len = a.length;
for (var x = 0; x < len; x++) {
writeHead.push(i + ": " + a[x]);
}
} else {
writeHead.push(i + ": " + proxyRes.headers[i]);
}
});
socket.write(writeHead.join('\r\n') + '\r\n\r\n');
proxySocket.pipe(socket).pipe(proxySocket);
server.emit('open', proxySocket);