mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
[api] emit a start an an end event
This commit is contained in:
parent
c6b7a7919f
commit
8b48a9fdab
@ -90,6 +90,13 @@ web_o = Object.keys(web_o).map(function(pass) {
|
||||
*/
|
||||
|
||||
function stream(req, res, options, _, server, clb) {
|
||||
|
||||
//
|
||||
// And we begin!
|
||||
//
|
||||
if (!clb) {
|
||||
server.emit('start', req, res, options.target)
|
||||
}
|
||||
if(options.forward) {
|
||||
// If forward enable, so just pipe the request
|
||||
var forwardReq = (options.forward.protocol === 'https:' ? https : http).request(
|
||||
@ -122,6 +129,15 @@ web_o = Object.keys(web_o).map(function(pass) {
|
||||
if(web_o[i](req, res, proxyRes)) { break; }
|
||||
}
|
||||
|
||||
//
|
||||
// Allow us to listen when the proxy has completed
|
||||
//
|
||||
proxyRes.on('end', function () {
|
||||
if (!clb) {
|
||||
server.emit('end', req, res, proxyRes);
|
||||
}
|
||||
})
|
||||
|
||||
proxyRes.pipe(res);
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user