11cb0ef41Sopenharmony_ci// Flags: --expose-internals 21cb0ef41Sopenharmony_ci'use strict'; 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst { kOutHeaders } = require('internal/http'); 71cb0ef41Sopenharmony_ciconst { OutgoingMessage } = require('http'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciconst warn = 'OutgoingMessage.prototype._headers is deprecated'; 101cb0ef41Sopenharmony_cicommon.expectWarning('DeprecationWarning', warn, 'DEP0066'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ci{ 131cb0ef41Sopenharmony_ci // Tests for _headers get method 141cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 151cb0ef41Sopenharmony_ci outgoingMessage.getHeaders = common.mustCall(); 161cb0ef41Sopenharmony_ci outgoingMessage._headers; // eslint-disable-line no-unused-expressions 171cb0ef41Sopenharmony_ci} 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci{ 201cb0ef41Sopenharmony_ci // Tests for _headers set method 211cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 221cb0ef41Sopenharmony_ci outgoingMessage._headers = { 231cb0ef41Sopenharmony_ci host: 'risingstack.com', 241cb0ef41Sopenharmony_ci Origin: 'localhost' 251cb0ef41Sopenharmony_ci }; 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci assert.deepStrictEqual( 281cb0ef41Sopenharmony_ci Object.entries(outgoingMessage[kOutHeaders]), 291cb0ef41Sopenharmony_ci Object.entries({ 301cb0ef41Sopenharmony_ci host: ['host', 'risingstack.com'], 311cb0ef41Sopenharmony_ci origin: ['Origin', 'localhost'] 321cb0ef41Sopenharmony_ci })); 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci{ 361cb0ef41Sopenharmony_ci // Tests for _headers set method `null` 371cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 381cb0ef41Sopenharmony_ci outgoingMessage._headers = null; 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci assert.strictEqual( 411cb0ef41Sopenharmony_ci outgoingMessage[kOutHeaders], 421cb0ef41Sopenharmony_ci null 431cb0ef41Sopenharmony_ci ); 441cb0ef41Sopenharmony_ci} 45