11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ciconst http = require('http'); 61cb0ef41Sopenharmony_ciconst { Agent } = require('_http_agent'); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst agent = new Agent({ 91cb0ef41Sopenharmony_ci keepAlive: true, 101cb0ef41Sopenharmony_ci keepAliveMsecs: 1000, 111cb0ef41Sopenharmony_ci}); 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => { 141cb0ef41Sopenharmony_ci res.end('ok'); 151cb0ef41Sopenharmony_ci})); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ciserver.listen(0, common.mustCall(() => { 181cb0ef41Sopenharmony_ci const createConnection = agent.createConnection; 191cb0ef41Sopenharmony_ci agent.createConnection = (options, ...args) => { 201cb0ef41Sopenharmony_ci assert.strictEqual(options.keepAlive, true); 211cb0ef41Sopenharmony_ci assert.strictEqual(options.keepAliveInitialDelay, agent.keepAliveMsecs); 221cb0ef41Sopenharmony_ci return createConnection.call(agent, options, ...args); 231cb0ef41Sopenharmony_ci }; 241cb0ef41Sopenharmony_ci http.get({ 251cb0ef41Sopenharmony_ci host: 'localhost', 261cb0ef41Sopenharmony_ci port: server.address().port, 271cb0ef41Sopenharmony_ci agent: agent, 281cb0ef41Sopenharmony_ci path: '/' 291cb0ef41Sopenharmony_ci }, common.mustCall((res) => { 301cb0ef41Sopenharmony_ci // for emit end event 311cb0ef41Sopenharmony_ci res.on('data', () => {}); 321cb0ef41Sopenharmony_ci res.on('end', () => { 331cb0ef41Sopenharmony_ci server.close(); 341cb0ef41Sopenharmony_ci }); 351cb0ef41Sopenharmony_ci })); 361cb0ef41Sopenharmony_ci})); 37