11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci// Flags: --expose-internals 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_cirequire('../common'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst kOutHeaders = require('internal/http').kOutHeaders; 81cb0ef41Sopenharmony_ciconst http = require('http'); 91cb0ef41Sopenharmony_ciconst OutgoingMessage = http.OutgoingMessage; 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ci{ 121cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 131cb0ef41Sopenharmony_ci outgoingMessage._header = {}; 141cb0ef41Sopenharmony_ci assert.throws( 151cb0ef41Sopenharmony_ci () => outgoingMessage._renderHeaders(), 161cb0ef41Sopenharmony_ci { 171cb0ef41Sopenharmony_ci code: 'ERR_HTTP_HEADERS_SENT', 181cb0ef41Sopenharmony_ci name: 'Error', 191cb0ef41Sopenharmony_ci message: 'Cannot render headers after they are sent to the client' 201cb0ef41Sopenharmony_ci } 211cb0ef41Sopenharmony_ci ); 221cb0ef41Sopenharmony_ci} 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci{ 251cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 261cb0ef41Sopenharmony_ci outgoingMessage[kOutHeaders] = null; 271cb0ef41Sopenharmony_ci const result = outgoingMessage._renderHeaders(); 281cb0ef41Sopenharmony_ci assert.deepStrictEqual(result, {}); 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci{ 331cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 341cb0ef41Sopenharmony_ci outgoingMessage[kOutHeaders] = {}; 351cb0ef41Sopenharmony_ci const result = outgoingMessage._renderHeaders(); 361cb0ef41Sopenharmony_ci assert.deepStrictEqual(result, {}); 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci{ 401cb0ef41Sopenharmony_ci const outgoingMessage = new OutgoingMessage(); 411cb0ef41Sopenharmony_ci outgoingMessage[kOutHeaders] = { 421cb0ef41Sopenharmony_ci host: ['host', 'nodejs.org'], 431cb0ef41Sopenharmony_ci origin: ['Origin', 'localhost'] 441cb0ef41Sopenharmony_ci }; 451cb0ef41Sopenharmony_ci const result = outgoingMessage._renderHeaders(); 461cb0ef41Sopenharmony_ci assert.deepStrictEqual(result, { 471cb0ef41Sopenharmony_ci host: 'nodejs.org', 481cb0ef41Sopenharmony_ci Origin: 'localhost' 491cb0ef41Sopenharmony_ci }); 501cb0ef41Sopenharmony_ci} 51