summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-abort-unix-socket.js
diff options
context:
space:
mode:
authorLuigi Pinca <luigipinca@gmail.com>2017-01-15 14:23:20 +0100
committerLuigi Pinca <luigipinca@gmail.com>2017-01-28 18:04:29 +0100
commit18d4ee97d812259eb11069614246c9adc5b9f719 (patch)
tree871ceeac8b056c0032a2f599c7c5e230132b3434 /test/parallel/test-http-client-abort-unix-socket.js
parent06ecf4dec70bc35dcdc32993a23ed6360a82a8b2 (diff)
downloadnode-new-18d4ee97d812259eb11069614246c9adc5b9f719.tar.gz
http: make request.abort() destroy the socket
`request.abort()` did not destroy the socket if it was called before a socket was assigned to the request and the request did not use an `Agent` or a Unix Domain Socket was used. Fixes: https://github.com/nodejs/node/issues/10812 PR-URL: https://github.com/nodejs/node/pull/10818 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'test/parallel/test-http-client-abort-unix-socket.js')
-rw-r--r--test/parallel/test-http-client-abort-unix-socket.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/parallel/test-http-client-abort-unix-socket.js b/test/parallel/test-http-client-abort-unix-socket.js
new file mode 100644
index 0000000000..0b7c5e5dde
--- /dev/null
+++ b/test/parallel/test-http-client-abort-unix-socket.js
@@ -0,0 +1,24 @@
+'use strict';
+const common = require('../common');
+const http = require('http');
+
+const server = http.createServer(common.fail);
+
+class Agent extends http.Agent {
+ createConnection(options, oncreate) {
+ const socket = super.createConnection(options, oncreate);
+ socket.once('close', () => server.close());
+ return socket;
+ }
+}
+
+common.refreshTmpDir();
+
+server.listen(common.PIPE, common.mustCall(() => {
+ const req = http.get({
+ agent: new Agent(),
+ socketPath: common.PIPE
+ });
+
+ req.abort();
+}));