Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions app/steps/sendProxyRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var chunkLength = require('../../lib/chunkLength');

function defaultSendProxyRequest(Container) {
var req = Container.user.req;
var res = Container.user.res;
var bodyContent = Container.proxy.bodyContent;
var reqOpt = Container.proxy.reqBuilder;
var options = Container.options;
Expand Down Expand Up @@ -67,11 +68,25 @@ function defaultSendProxyRequest(Container) {
req.pipe(proxyReq);
}

req.on('aborted', function () {
// reject?
// 'aborted' event stopped working reliably on v15.5.0 and was later removed entirely
var supportsAbortedEvent = (function () {
var ver = process.versions.node.split('.').map(Number);
return ver[0] <= 14 || ver[0] === 15 && ver[1] <= 4;
}());

proxyReq.abort();
});
if (supportsAbortedEvent) {
req.on('aborted', function () {
// reject?
proxyReq.abort();
});
} else {
res.on('close', function () {
var aborted = !res.writableFinished;
if (aborted) {
proxyReq.abort();
}
});
}
});
}

Expand Down