Skip to content

Commit d0862af

Browse files
committedNov 7, 2013
[fix] merge #495, thanks @glasser
1 parent cde08fb commit d0862af

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed
 

Diff for: ‎lib/http-proxy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ proxy.createProxyServer = proxy.createServer = function createProxyServer(option
3636
* `options.target and `options.forward` cannot be
3737
* both missing
3838
* }
39-
*/
39+
*/
4040

4141
return new httpProxy.Server(options);
4242
};

Diff for: ‎lib/http-proxy/passes/ws-incoming.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,11 @@ var passes = exports;
106106
common.setupOutgoing(options.ssl || {}, options, req)
107107
);
108108
// Error Handler
109-
proxyReq.on('error', function(err){
110-
if (clb) {
111-
clb(err);
112-
} else {
113-
server.emit('error', err, req, res);
114-
}
115-
});
109+
proxyReq.on('error', onError);
116110

117111
proxyReq.on('upgrade', function(proxyRes, proxySocket, proxyHead) {
112+
proxySocket.on('error', onError);
113+
118114
common.setupSocket(proxySocket);
119115

120116
if (proxyHead && proxyHead.length) proxySocket.unshift(proxyHead);
@@ -126,7 +122,15 @@ var passes = exports;
126122
proxySocket.pipe(socket).pipe(proxySocket);
127123
});
128124

129-
proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
125+
return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
126+
127+
function onError(err) {
128+
if (clb) {
129+
clb(err);
130+
} else {
131+
server.emit('error', err, req, res);
132+
}
133+
}
130134
}
131135

132136
] // <--

0 commit comments

Comments
 (0)
Please sign in to comment.