1'use strict'; 2 3const common = require('../common'); 4const http = require('http'); 5const assert = require('assert'); 6 7const server = http.createServer(common.mustCall((req, res) => { 8 const body = 'hello world\n'; 9 10 res.writeHead(200, { 'Content-Length': body.length }); 11 res.write(body); 12 res.end(); 13})); 14server.keepAliveTimeout = 12010; 15 16const agent = new http.Agent({ maxSockets: 1, keepAlive: true }); 17 18server.listen(0, common.mustCall(function() { 19 http.get({ 20 path: '/', port: this.address().port, agent: agent 21 }, common.mustCall((response) => { 22 response.resume(); 23 assert.strictEqual( 24 response.headers['keep-alive'], 'timeout=12'); 25 server.close(); 26 agent.destroy(); 27 })); 28})); 29