mirror of
https://github.com/http-party/node-http-proxy.git
synced 2025-12-08 20:59:18 +00:00
Handle cases where res.write throws
This commit is contained in:
parent
5d0bbb38c3
commit
be3a0d84a1
@ -513,9 +513,17 @@ HttpProxy.prototype.proxyRequest = function (req, res, options) {
|
||||
|
||||
// For each data `chunk` received from the `reverseProxy`
|
||||
// `response` write it to the outgoing `res`.
|
||||
// If the res socket has been killed already, then write()
|
||||
// will throw. Nevertheless, try our best to end it nicely.
|
||||
response.on('data', function (chunk) {
|
||||
if (req.method !== 'HEAD') {
|
||||
if (req.method !== 'HEAD' && res.writable) {
|
||||
try {
|
||||
res.write(chunk);
|
||||
} catch (er) {
|
||||
try {
|
||||
res.end();
|
||||
} catch (er) {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user