11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst assert = require('assert');
41cb0ef41Sopenharmony_ciconst http = require('http');
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci{
71cb0ef41Sopenharmony_ci  const server = http.createServer({
81cb0ef41Sopenharmony_ci    requireHostHeader: false,
91cb0ef41Sopenharmony_ci    joinDuplicateHeaders: true
101cb0ef41Sopenharmony_ci  }, common.mustCall((req, res) => {
111cb0ef41Sopenharmony_ci    assert.strictEqual(req.headers.authorization, '1, 2');
121cb0ef41Sopenharmony_ci    assert.strictEqual(req.headers.cookie, 'foo; bar');
131cb0ef41Sopenharmony_ci    res.writeHead(200, ['authorization', '3', 'authorization', '4', 'cookie', 'foo', 'cookie', 'bar']);
141cb0ef41Sopenharmony_ci    res.end();
151cb0ef41Sopenharmony_ci  }));
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ci  server.listen(0, common.mustCall(() => {
181cb0ef41Sopenharmony_ci    http.get({
191cb0ef41Sopenharmony_ci      port: server.address().port,
201cb0ef41Sopenharmony_ci      headers: ['authorization', '1', 'authorization', '2', 'cookie', 'foo', 'cookie', 'bar'],
211cb0ef41Sopenharmony_ci      joinDuplicateHeaders: true
221cb0ef41Sopenharmony_ci    }, (res) => {
231cb0ef41Sopenharmony_ci      assert.strictEqual(res.statusCode, 200);
241cb0ef41Sopenharmony_ci      assert.strictEqual(res.headers.authorization, '3, 4');
251cb0ef41Sopenharmony_ci      assert.strictEqual(res.headers.cookie, 'foo; bar');
261cb0ef41Sopenharmony_ci      res.resume().on('end', common.mustCall(() => {
271cb0ef41Sopenharmony_ci        server.close();
281cb0ef41Sopenharmony_ci      }));
291cb0ef41Sopenharmony_ci    });
301cb0ef41Sopenharmony_ci  }));
311cb0ef41Sopenharmony_ci}
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci{
341cb0ef41Sopenharmony_ci  // Server joinDuplicateHeaders false
351cb0ef41Sopenharmony_ci  const server = http.createServer({
361cb0ef41Sopenharmony_ci    requireHostHeader: false,
371cb0ef41Sopenharmony_ci    joinDuplicateHeaders: false
381cb0ef41Sopenharmony_ci  }, common.mustCall((req, res) => {
391cb0ef41Sopenharmony_ci    assert.strictEqual(req.headers.authorization, '1'); // non joined value
401cb0ef41Sopenharmony_ci    res.writeHead(200, ['authorization', '3', 'authorization', '4']);
411cb0ef41Sopenharmony_ci    res.end();
421cb0ef41Sopenharmony_ci  }));
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci  server.listen(0, common.mustCall(() => {
451cb0ef41Sopenharmony_ci    http.get({
461cb0ef41Sopenharmony_ci      port: server.address().port,
471cb0ef41Sopenharmony_ci      headers: ['authorization', '1', 'authorization', '2'],
481cb0ef41Sopenharmony_ci      joinDuplicateHeaders: true
491cb0ef41Sopenharmony_ci    }, (res) => {
501cb0ef41Sopenharmony_ci      assert.strictEqual(res.statusCode, 200);
511cb0ef41Sopenharmony_ci      assert.strictEqual(res.headers.authorization, '3, 4');
521cb0ef41Sopenharmony_ci      res.resume().on('end', common.mustCall(() => {
531cb0ef41Sopenharmony_ci        server.close();
541cb0ef41Sopenharmony_ci      }));
551cb0ef41Sopenharmony_ci    });
561cb0ef41Sopenharmony_ci  }));
571cb0ef41Sopenharmony_ci}
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci{
601cb0ef41Sopenharmony_ci  // Client joinDuplicateHeaders false
611cb0ef41Sopenharmony_ci  const server = http.createServer({
621cb0ef41Sopenharmony_ci    requireHostHeader: false,
631cb0ef41Sopenharmony_ci    joinDuplicateHeaders: true
641cb0ef41Sopenharmony_ci  }, common.mustCall((req, res) => {
651cb0ef41Sopenharmony_ci    assert.strictEqual(req.headers.authorization, '1, 2');
661cb0ef41Sopenharmony_ci    res.writeHead(200, ['authorization', '3', 'authorization', '4']);
671cb0ef41Sopenharmony_ci    res.end();
681cb0ef41Sopenharmony_ci  }));
691cb0ef41Sopenharmony_ci
701cb0ef41Sopenharmony_ci  server.listen(0, common.mustCall(() => {
711cb0ef41Sopenharmony_ci    http.get({
721cb0ef41Sopenharmony_ci      port: server.address().port,
731cb0ef41Sopenharmony_ci      headers: ['authorization', '1', 'authorization', '2'],
741cb0ef41Sopenharmony_ci      joinDuplicateHeaders: false
751cb0ef41Sopenharmony_ci    }, (res) => {
761cb0ef41Sopenharmony_ci      assert.strictEqual(res.statusCode, 200);
771cb0ef41Sopenharmony_ci      assert.strictEqual(res.headers.authorization, '3'); // non joined value
781cb0ef41Sopenharmony_ci      res.resume().on('end', common.mustCall(() => {
791cb0ef41Sopenharmony_ci        server.close();
801cb0ef41Sopenharmony_ci      }));
811cb0ef41Sopenharmony_ci    });
821cb0ef41Sopenharmony_ci  }));
831cb0ef41Sopenharmony_ci}
84