mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Merge pull request #709 from minrk/close-on-error
close socket if upstream request fails
This commit is contained in:
commit
fcdbf46e4d
@ -124,6 +124,7 @@ var passes = exports;
|
|||||||
} else {
|
} else {
|
||||||
server.emit('error', err, req, socket);
|
server.emit('error', err, req, socket);
|
||||||
}
|
}
|
||||||
|
socket.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -280,17 +280,24 @@ describe('lib/http-proxy.js', function() {
|
|||||||
client.on('open', function () {
|
client.on('open', function () {
|
||||||
client.send('hello there');
|
client.send('hello there');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
function maybe_done () {
|
||||||
|
count += 1;
|
||||||
|
if (count === 2) done();
|
||||||
|
}
|
||||||
|
|
||||||
client.on('error', function (err) {
|
client.on('error', function (err) {
|
||||||
expect(err).to.be.an(Error);
|
expect(err).to.be.an(Error);
|
||||||
expect(err.code).to.be('ECONNRESET');
|
expect(err.code).to.be('ECONNRESET');
|
||||||
|
maybe_done();
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy.on('error', function (err) {
|
proxy.on('error', function (err) {
|
||||||
expect(err).to.be.an(Error);
|
expect(err).to.be.an(Error);
|
||||||
expect(err.code).to.be('ECONNREFUSED');
|
expect(err.code).to.be('ECONNREFUSED');
|
||||||
proxyServer.close();
|
proxyServer.close();
|
||||||
done();
|
maybe_done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user