11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst http = require('http');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst expected = {
61cb0ef41Sopenharmony_ci  '__proto__': null,
71cb0ef41Sopenharmony_ci  'testheader1': 'foo',
81cb0ef41Sopenharmony_ci  'testheader2': 'bar',
91cb0ef41Sopenharmony_ci  'testheader3': 'xyz'
101cb0ef41Sopenharmony_ci};
111cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall((req, res) => {
121cb0ef41Sopenharmony_ci  let retval = res.setHeader('testheader1', 'foo');
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  // Test that the setHeader returns the same response object.
151cb0ef41Sopenharmony_ci  assert.strictEqual(retval, res);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  retval = res.setHeader('testheader2', 'bar').setHeader('testheader3', 'xyz');
181cb0ef41Sopenharmony_ci  // Test that chaining works for setHeader.
191cb0ef41Sopenharmony_ci  assert.deepStrictEqual(res.getHeaders(), expected);
201cb0ef41Sopenharmony_ci  res.end('ok');
211cb0ef41Sopenharmony_ci}));
221cb0ef41Sopenharmony_ciserver.listen(0, () => {
231cb0ef41Sopenharmony_ci  http.get({ port: server.address().port }, common.mustCall((res) => {
241cb0ef41Sopenharmony_ci    res.on('data', () => {});
251cb0ef41Sopenharmony_ci    res.on('end', common.mustCall(() => {
261cb0ef41Sopenharmony_ci      server.close();
271cb0ef41Sopenharmony_ci    }));
281cb0ef41Sopenharmony_ci  }));
291cb0ef41Sopenharmony_ci});
30