Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/http-proxy/passes/web-incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,14 @@ web_o = Object.keys(web_o).map(function(pass) {
proxyReq.abort();
});

// Handle errors on incoming request as well as it makes sense to
req.on('error', proxyError);

// Error Handler
proxyReq.on('error', proxyError);

function proxyError (err){
if (clb) {
clb(err, req, res, options.target);
clb(err, proxyReq, options.target);
} else {
server.emit('error', err, req, res, options.target);
server.emit('error', err, proxyReq, options.target);
}
}

Expand Down
12 changes: 3 additions & 9 deletions test/lib-http-proxy-passes-web-incoming-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,9 @@ describe('#createProxyServer.web() using own http server', function () {
var proxyServer = http.createServer(requestHandler);

function requestHandler(req, res) {
proxy.once('error', function (err, errReq, errRes) {
proxy.once('error', function (err) {
proxyServer.close();
expect(err).to.be.an(Error);
expect(errReq).to.be.equal(req);
expect(errRes).to.be.equal(res);
expect(err.code).to.be('ECONNREFUSED');
done();
});
Expand Down Expand Up @@ -177,11 +175,9 @@ describe('#createProxyServer.web() using own http server', function () {

var started = new Date().getTime();
function requestHandler(req, res) {
proxy.once('error', function (err, errReq, errRes) {
proxy.once('error', function (err) {
proxyServer.close();
expect(err).to.be.an(Error);
expect(errReq).to.be.equal(req);
expect(errRes).to.be.equal(res);
expect(new Date().getTime() - started).to.be.greaterThan(99);
expect(err.code).to.be('ECONNRESET');
done();
Expand Down Expand Up @@ -217,11 +213,9 @@ describe('#createProxyServer.web() using own http server', function () {

var started = new Date().getTime();
function requestHandler(req, res) {
proxy.once('error', function (err, errReq, errRes) {
proxy.once('error', function (err) {
proxyServer.close();
expect(err).to.be.an(Error);
expect(errReq).to.be.equal(req);
expect(errRes).to.be.equal(res);
expect(err.code).to.be('ECONNRESET');
doneOne();
});
Expand Down