mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
emitting proxySocket on proxyServer
- emitted once proxySocket was created and socket was piped into it - needed to support sniffing messages coming from proxy target
This commit is contained in:
parent
2aa3b84d7b
commit
000eb533de
@ -190,6 +190,7 @@ http.createServer(function (req, res) {
|
||||
|
||||
* `error`: The error event is emitted if the request to the target fail.
|
||||
* `proxyRes`: This event is emitted if the request to the target got a response.
|
||||
* `proxySocket`: This event is emitted once the proxy websocket was created and piped into the target websocket.
|
||||
|
||||
```js
|
||||
var httpProxy = require('http-proxy');
|
||||
@ -220,6 +221,13 @@ proxy.on('proxyRes', function (proxyRes, req, res) {
|
||||
console.log('RAW Response from the target', JSON.stringify(proxyRes.headers, true, 2));
|
||||
});
|
||||
|
||||
//
|
||||
// Listen for the `proxySocket` event on `proxy`.
|
||||
//
|
||||
proxy.on('proxySocket', function (proxySocket) {
|
||||
// listen for messages coming FROM the target here
|
||||
proxySocket.on('data', hybiParseAndLogMessage);
|
||||
});
|
||||
```
|
||||
|
||||
#### Using HTTPS
|
||||
|
||||
@ -108,6 +108,7 @@ var passes = exports;
|
||||
return i + ": " + proxyRes.headers[i];
|
||||
}).join('\r\n') + '\r\n\r\n');
|
||||
proxySocket.pipe(socket).pipe(proxySocket);
|
||||
server.emit('proxySocket', proxySocket);
|
||||
});
|
||||
|
||||
return proxyReq.end(); // XXX: CHECK IF THIS IS THIS CORRECT
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user