Merge pull request #709 from minrk/close-on-error

close socket if upstream request fails
This commit is contained in:
Jarrett Cruger 2014-10-01 07:10:22 -04:00
commit fcdbf46e4d
2 changed files with 9 additions and 1 deletions

View File

@ -124,6 +124,7 @@ var passes = exports;
} else {
server.emit('error', err, req, socket);
}
socket.end();
}
}

View File

@ -280,17 +280,24 @@ describe('lib/http-proxy.js', function() {
client.on('open', function () {
client.send('hello there');
});
var count = 0;
function maybe_done () {
count += 1;
if (count === 2) done();
}
client.on('error', function (err) {
expect(err).to.be.an(Error);
expect(err.code).to.be('ECONNRESET');
maybe_done();
});
proxy.on('error', function (err) {
expect(err).to.be.an(Error);
expect(err.code).to.be('ECONNREFUSED');
proxyServer.close();
done();
maybe_done();
});
});