summaryrefslogtreecommitdiff
path: root/test/parallel/test-http-agent-remove.js
diff options
context:
space:
mode:
authorLuigi Pinca <luigipinca@gmail.com>2018-05-16 22:15:20 +0200
committerAnatoli Papirovski <apapirovski@mac.com>2018-05-22 12:10:22 +0400
commit4a940aadfabc35be404da64e9ab7014a8cc71728 (patch)
treebe08259aa783d3d3f496ec18eaddea10ca3db417 /test/parallel/test-http-agent-remove.js
parentef9d0ae6f209851dd43d7d24b12e19547bcf0dbf (diff)
downloadandroid-node-v8-4a940aadfabc35be404da64e9ab7014a8cc71728.tar.gz
android-node-v8-4a940aadfabc35be404da64e9ab7014a8cc71728.tar.bz2
android-node-v8-4a940aadfabc35be404da64e9ab7014a8cc71728.zip
http: do not rely on the 'agentRemove' event
Do not use the `'agentRemove'` event to null `socket._httpMessage` as that event is public and can be used to not keep a request in the agent. PR-URL: https://github.com/nodejs/node/pull/20786 Fixes: https://github.com/nodejs/node/issues/20690 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'test/parallel/test-http-agent-remove.js')
-rw-r--r--test/parallel/test-http-agent-remove.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/parallel/test-http-agent-remove.js b/test/parallel/test-http-agent-remove.js
new file mode 100644
index 0000000000..24fc7fcb82
--- /dev/null
+++ b/test/parallel/test-http-agent-remove.js
@@ -0,0 +1,21 @@
+'use strict';
+const { mustCall } = require('../common');
+
+const http = require('http');
+const { strictEqual } = require('assert');
+
+const server = http.createServer(mustCall((req, res) => {
+ res.flushHeaders();
+}));
+
+server.listen(0, mustCall(() => {
+ const req = http.get({
+ port: server.address().port
+ }, mustCall(() => {
+ const { socket } = req;
+ socket.emit('agentRemove');
+ strictEqual(socket._httpMessage, req);
+ socket.destroy();
+ server.close();
+ }));
+}));