mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Further cleanup
This commit is contained in:
parent
fce7550609
commit
37ef3e187b
1 changed files with 10 additions and 4 deletions
|
|
@ -23,9 +23,17 @@ export function handleHttpProxyRequest(req, res) {
|
||||||
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
||||||
proxyRes.pipe(res);
|
proxyRes.pipe(res);
|
||||||
|
|
||||||
|
proxyRes.on("error", () => {
|
||||||
|
// Proxy response stream error
|
||||||
|
// Clean up client response stream
|
||||||
|
if (res.writable) {
|
||||||
|
res.end();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
proxyRes.on("close", () => {
|
proxyRes.on("close", () => {
|
||||||
// Clean up if the proxy response stream closes
|
// Clean up if the proxy response stream closes
|
||||||
if (!res.writableEnded) {
|
if (res.writable) {
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -51,9 +59,7 @@ export function handleHttpProxyRequest(req, res) {
|
||||||
res.on("close", () => {
|
res.on("close", () => {
|
||||||
// Client disconnected
|
// Client disconnected
|
||||||
// Abort the proxy request to avoid unnecessary work
|
// Abort the proxy request to avoid unnecessary work
|
||||||
if (!res.writableEnded) {
|
|
||||||
proxyRequest.destroy();
|
proxyRequest.destroy();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
req.pipe(proxyRequest);
|
req.pipe(proxyRequest);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue