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, { 11 'Content-Length': body.length, 12 'Keep-Alive': 'timeout=50' 13 }); 14 res.write(body); 15 res.end(); 16})); 17server.keepAliveTimeout = 12010; 18 19const agent = new http.Agent({ maxSockets: 1, keepAlive: true }); 20 21server.listen(0, common.mustCall(function() { 22 http.get({ 23 path: '/', port: this.address().port, agent: agent 24 }, common.mustCall((response) => { 25 response.resume(); 26 assert.strictEqual( 27 response.headers['keep-alive'], 'timeout=50'); 28 server.close(); 29 agent.destroy(); 30 })); 31})); 32