11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst http = require('http');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => {
71cb0ef41Sopenharmony_ci  res.setHeader('X-Date', 'foo');
81cb0ef41Sopenharmony_ci  res.setHeader('X-Connection', 'bar');
91cb0ef41Sopenharmony_ci  res.setHeader('X-Content-Length', 'baz');
101cb0ef41Sopenharmony_ci  res.end();
111cb0ef41Sopenharmony_ci}));
121cb0ef41Sopenharmony_ciserver.listen(0);
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ciserver.on('listening', common.mustCall(() => {
151cb0ef41Sopenharmony_ci  const agent = new http.Agent({ port: server.address().port, maxSockets: 1 });
161cb0ef41Sopenharmony_ci  http.get({
171cb0ef41Sopenharmony_ci    port: server.address().port,
181cb0ef41Sopenharmony_ci    path: '/hello',
191cb0ef41Sopenharmony_ci    agent: agent
201cb0ef41Sopenharmony_ci  }, common.mustCall((res) => {
211cb0ef41Sopenharmony_ci    assert.strictEqual(res.statusCode, 200);
221cb0ef41Sopenharmony_ci    assert.strictEqual(res.headers['x-date'], 'foo');
231cb0ef41Sopenharmony_ci    assert.strictEqual(res.headers['x-connection'], 'bar');
241cb0ef41Sopenharmony_ci    assert.strictEqual(res.headers['x-content-length'], 'baz');
251cb0ef41Sopenharmony_ci    assert(res.headers.date);
261cb0ef41Sopenharmony_ci    assert.strictEqual(res.headers.connection, 'keep-alive');
271cb0ef41Sopenharmony_ci    assert.strictEqual(res.headers['content-length'], '0');
281cb0ef41Sopenharmony_ci    server.close();
291cb0ef41Sopenharmony_ci    agent.destroy();
301cb0ef41Sopenharmony_ci  }));
311cb0ef41Sopenharmony_ci}));
32