Skip to content

Commit 5df6e7b

Browse files
committed
http-proxy: emit websocket:start
* routing-proxy: allow listening for websocket:* event
1 parent 1df2b30 commit 5df6e7b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/node-http-proxy/http-proxy.js

+2
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ HttpProxy.prototype.proxyWebSocketRequest = function (req, socket, head, buffer)
437437
}
438438
}
439439

440+
self.emit('websocket:start', req, socket, head, this.target);
441+
440442
//
441443
// Helper function for setting appropriate socket values:
442444
// 1. Turn of all bufferings

lib/node-http-proxy/routing-proxy.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,17 @@ RoutingProxy.prototype.add = function (options) {
111111
this.proxies[key].on('webSocketProxyError', this.emit.bind(this, 'webSocketProxyError'));
112112
}
113113

114-
this.proxies[key].on('start', this.emit.bind(this, 'start'));
115-
this.proxies[key].on('forward', this.emit.bind(this, 'forward'));
116-
this.proxies[key].on('end', this.emit.bind(this, 'end'));
114+
[
115+
'start',
116+
'forward',
117+
'end',
118+
'websocket:start',
119+
'websocket:end',
120+
'websocket:incoming',
121+
'websocket:outgoing'
122+
].forEach(function(event) {
123+
this.proxies[key].on(event, this.emit.bind(this, event));
124+
}, this);
117125
};
118126

119127
//

0 commit comments

Comments
 (0)