From 02df9a33c5cce17ea32a892017acbe5ce57ab2e5 Mon Sep 17 00:00:00 2001 From: cronopio Date: Mon, 21 Oct 2013 23:22:32 -0500 Subject: [PATCH] [fix] fix the correct order of arguments in ws-incoming passes --- lib/http-proxy/passes/ws-incoming.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/http-proxy/passes/ws-incoming.js b/lib/http-proxy/passes/ws-incoming.js index 66c75d5..ebdbe2a 100644 --- a/lib/http-proxy/passes/ws-incoming.js +++ b/lib/http-proxy/passes/ws-incoming.js @@ -96,22 +96,21 @@ var passes = exports; * * @api private */ - function stream(req, socket, server, head, clb) { + function stream(req, socket, options, server, head, clb) { common.setupSocket(socket); if (head && head.length) socket.unshift(head); - var proxyReq = (~['https:', 'wss:'].indexOf(server.options.target.protocol) ? https : http).request( - common.setupOutgoing(server.options.ssl || {}, server.options, req) + var proxyReq = (~['https:', 'wss:'].indexOf(options.target.protocol) ? https : http).request( + common.setupOutgoing(options.ssl || {}, options, req) ); // Error Handler proxyReq.on('error', function(err){ - if(server) { - server.emit('error', err); - } - else { + if (clb) { clb(err); + } else { + server.emit('error', err, req, res); } });