-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #13981 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
- Loading branch information
1 parent
8490176
commit 7a654eb
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
// Flags: --expose-internals | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
|
||
const outHeadersKey = require('internal/http').outHeadersKey; | ||
const http = require('http'); | ||
const OutgoingMessage = http.OutgoingMessage; | ||
|
||
{ | ||
const outgoingMessage = new OutgoingMessage(); | ||
outgoingMessage._header = {}; | ||
assert.throws( | ||
outgoingMessage._renderHeaders.bind(outgoingMessage), | ||
/^Error: Can't render headers after they are sent to the client$/ | ||
); | ||
} | ||
|
||
{ | ||
const outgoingMessage = new OutgoingMessage(); | ||
outgoingMessage[outHeadersKey] = null; | ||
const result = outgoingMessage._renderHeaders(); | ||
assert.deepStrictEqual(result, {}); | ||
} | ||
|
||
|
||
{ | ||
const outgoingMessage = new OutgoingMessage(); | ||
outgoingMessage[outHeadersKey] = {}; | ||
const result = outgoingMessage._renderHeaders(); | ||
assert.deepStrictEqual(result, {}); | ||
} | ||
|
||
{ | ||
const outgoingMessage = new OutgoingMessage(); | ||
outgoingMessage[outHeadersKey] = { | ||
host: ['host', 'nodejs.org'], | ||
origin: ['Origin', 'localhost'] | ||
}; | ||
const result = outgoingMessage._renderHeaders(); | ||
assert.deepStrictEqual(result, { | ||
host: 'nodejs.org', | ||
Origin: 'localhost' | ||
}); | ||
} |