From 8bfd90c4d9331fd129f17a788ef9fc733654b7e0 Mon Sep 17 00:00:00 2001 From: Arttu Liimola Date: Thu, 27 Aug 2015 12:53:43 +0300 Subject: [PATCH] Use raw headers instead parsed. Set-Cookie headers are parsed into single header with cookies in array. This messes up the Set-Cookie headers, because browser receives multiple Set-Cookie headers as single with cookies separted with comma. --- lib/http-proxy/passes/ws-incoming.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/http-proxy/passes/ws-incoming.js b/lib/http-proxy/passes/ws-incoming.js index 8264be6..1284f64 100644 --- a/lib/http-proxy/passes/ws-incoming.js +++ b/lib/http-proxy/passes/ws-incoming.js @@ -114,8 +114,10 @@ var passes = exports; if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead); socket.write('HTTP/1.1 101 Switching Protocols\r\n'); - socket.write(Object.keys(proxyRes.headers).map(function(i) { - return i + ": " + proxyRes.headers[i]; + 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'); proxySocket.pipe(socket).pipe(proxySocket);