11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst http = require('http'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_cifor (const method of ['abort', 'destroy']) { 91cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall((req, res) => { 101cb0ef41Sopenharmony_ci res.end(req.url); 111cb0ef41Sopenharmony_ci })); 121cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 131cb0ef41Sopenharmony_ci const agent = http.Agent({ keepAlive: true }); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci const req = http 161cb0ef41Sopenharmony_ci .request({ 171cb0ef41Sopenharmony_ci port: server.address().port, 181cb0ef41Sopenharmony_ci agent 191cb0ef41Sopenharmony_ci }) 201cb0ef41Sopenharmony_ci .on('socket', common.mustCall((socket) => { 211cb0ef41Sopenharmony_ci socket.on('free', common.mustCall()); 221cb0ef41Sopenharmony_ci })) 231cb0ef41Sopenharmony_ci .on('response', common.mustCall((res) => { 241cb0ef41Sopenharmony_ci assert.strictEqual(req.destroyed, false); 251cb0ef41Sopenharmony_ci res.on('end', () => { 261cb0ef41Sopenharmony_ci assert.strictEqual(req.destroyed, true); 271cb0ef41Sopenharmony_ci req[method](); 281cb0ef41Sopenharmony_ci assert.strictEqual(req.socket.destroyed, false); 291cb0ef41Sopenharmony_ci agent.destroy(); 301cb0ef41Sopenharmony_ci server.close(); 311cb0ef41Sopenharmony_ci }).resume(); 321cb0ef41Sopenharmony_ci })) 331cb0ef41Sopenharmony_ci .end(); 341cb0ef41Sopenharmony_ci assert.strictEqual(req.destroyed, false); 351cb0ef41Sopenharmony_ci })); 361cb0ef41Sopenharmony_ci} 37