-
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: #46528 Fixes: #46395 Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Robert Nagy <ronagy@icloud.com>
- Loading branch information
1 parent
2eb8875
commit 6f9cb98
Showing
2 changed files
with
61 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
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,48 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
const nonUtf8Header = 'bår'; | ||
const nonUtf8ToLatin1 = Buffer.from(nonUtf8Header).toString('latin1'); | ||
|
||
{ | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.writeHead(200, [ | ||
'content-disposition', | ||
Buffer.from(nonUtf8Header).toString('binary'), | ||
]); | ||
res.end('hello'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
http.get({ port: server.address().port }, (res) => { | ||
assert.strictEqual(res.statusCode, 200); | ||
assert.strictEqual(res.headers['content-disposition'], nonUtf8ToLatin1); | ||
res.resume().on('end', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
}); | ||
})); | ||
} | ||
|
||
{ | ||
const server = http.createServer(common.mustCall((req, res) => { | ||
res.writeHead(200, [ | ||
'Content-Length', '5', | ||
'content-disposition', | ||
Buffer.from(nonUtf8Header).toString('binary'), | ||
]); | ||
res.end('hello'); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
http.get({ port: server.address().port }, (res) => { | ||
assert.strictEqual(res.statusCode, 200); | ||
assert.strictEqual(res.headers['content-disposition'], nonUtf8ToLatin1); | ||
res.resume().on('end', common.mustCall(() => { | ||
server.close(); | ||
})); | ||
}); | ||
})); | ||
} |