• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Flags: --expose-internals
2'use strict';
3const common = require('../common');
4const assert = require('assert');
5
6const { kOutHeaders } = require('internal/http');
7const { OutgoingMessage } = require('http');
8
9const warn = 'OutgoingMessage.prototype._headers is deprecated';
10common.expectWarning('DeprecationWarning', warn, 'DEP0066');
11
12{
13  // Tests for _headers get method
14  const outgoingMessage = new OutgoingMessage();
15  outgoingMessage.getHeaders = common.mustCall();
16  outgoingMessage._headers; // eslint-disable-line no-unused-expressions
17}
18
19{
20  // Tests for _headers set method
21  const outgoingMessage = new OutgoingMessage();
22  outgoingMessage._headers = {
23    host: 'risingstack.com',
24    Origin: 'localhost'
25  };
26
27  assert.deepStrictEqual(
28    Object.entries(outgoingMessage[kOutHeaders]),
29    Object.entries({
30      host: ['host', 'risingstack.com'],
31      origin: ['Origin', 'localhost']
32    }));
33}
34
35{
36  // Tests for _headers set method `null`
37  const outgoingMessage = new OutgoingMessage();
38  outgoingMessage._headers = null;
39
40  assert.strictEqual(
41    outgoingMessage[kOutHeaders],
42    null
43  );
44}
45