From 9ba8311343fd01b32505b8607ecf4294200f9dde Mon Sep 17 00:00:00 2001
From: jleal52 <joorge@gmail.com>
Date: Wed, 12 Nov 2014 14:41:46 +0000
Subject: [PATCH] Updated to support error callback on proxy.web and
 start/proxyReq/end continue working.

---
 lib/http-proxy/index.js               | 2 +-
 lib/http-proxy/passes/web-incoming.js | 6 +-----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/lib/http-proxy/index.js b/lib/http-proxy/index.js
index 8767dfb..ba04e0d 100644
--- a/lib/http-proxy/index.js
+++ b/lib/http-proxy/index.js
@@ -77,7 +77,7 @@ function createRightProxy(type) {
          * refer to the connection socket
          * pass(req, socket, options, head)
          */
-        if(passes[i](req, res, options, head, cbl ? false : this, cbl)) { // passes can return a truthy value to halt the loop
+        if(passes[i](req, res, options, head, this, cbl)) { // passes can return a truthy value to halt the loop
           break;
         }
       }
diff --git a/lib/http-proxy/passes/web-incoming.js b/lib/http-proxy/passes/web-incoming.js
index c7805a4..572c11a 100644
--- a/lib/http-proxy/passes/web-incoming.js
+++ b/lib/http-proxy/passes/web-incoming.js
@@ -92,9 +92,7 @@ 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)
-    }
+    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(
@@ -151,9 +149,7 @@ web_o = Object.keys(web_o).map(function(pass) {
 
       // Allow us to listen when the proxy has completed
       proxyRes.on('end', function () {
-        if (!clb) {
           server.emit('end', req, res, proxyRes);
-        }
       })
 
       proxyRes.pipe(res);
-- 
GitLab