summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-client-abort-no-agent.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-no-agent.js
parent06ecf4dec70bc35dcdc32993a23ed6360a82a8b2 (diff)
downloadandroid-node-v8-18d4ee97d812259eb11069614246c9adc5b9f719.tar.gz
android-node-v8-18d4ee97d812259eb11069614246c9adc5b9f719.tar.bz2
android-node-v8-18d4ee97d812259eb11069614246c9adc5b9f719.zip
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-no-agent.js')
-rw-r--r--test/parallel/test-http-client-abort-no-agent.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/parallel/test-http-client-abort-no-agent.js b/test/parallel/test-http-client-abort-no-agent.js
new file mode 100644
index 0000000000..875d2ce646
--- /dev/null
+++ b/test/parallel/test-http-client-abort-no-agent.js
@@ -0,0 +1,19 @@
+'use strict';
+const common = require('../common');
+const http = require('http');
+const net = require('net');
+
+const server = http.createServer(common.fail);
+
+server.listen(0, common.mustCall(() => {
+ const req = http.get({
+ createConnection(options, oncreate) {
+ const socket = net.createConnection(options, oncreate);
+ socket.once('close', () => server.close());
+ return socket;
+ },
+ port: server.address().port
+ });
+
+ req.abort();
+}));