11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ciconst common = require('../common'); 31cb0ef41Sopenharmony_ciconst http = require('http'); 41cb0ef41Sopenharmony_ciconst assert = require('assert'); 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ciconst nonUtf8Header = 'bår'; 71cb0ef41Sopenharmony_ciconst nonUtf8ToLatin1 = Buffer.from(nonUtf8Header).toString('latin1'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci{ 101cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall((req, res) => { 111cb0ef41Sopenharmony_ci res.writeHead(200, [ 121cb0ef41Sopenharmony_ci 'content-disposition', 131cb0ef41Sopenharmony_ci Buffer.from(nonUtf8Header).toString('binary'), 141cb0ef41Sopenharmony_ci ]); 151cb0ef41Sopenharmony_ci res.end('hello'); 161cb0ef41Sopenharmony_ci })); 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 191cb0ef41Sopenharmony_ci http.get({ port: server.address().port }, (res) => { 201cb0ef41Sopenharmony_ci assert.strictEqual(res.statusCode, 200); 211cb0ef41Sopenharmony_ci assert.strictEqual(res.headers['content-disposition'], nonUtf8ToLatin1); 221cb0ef41Sopenharmony_ci res.resume().on('end', common.mustCall(() => { 231cb0ef41Sopenharmony_ci server.close(); 241cb0ef41Sopenharmony_ci })); 251cb0ef41Sopenharmony_ci }); 261cb0ef41Sopenharmony_ci })); 271cb0ef41Sopenharmony_ci} 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci{ 301cb0ef41Sopenharmony_ci const server = http.createServer(common.mustCall((req, res) => { 311cb0ef41Sopenharmony_ci res.writeHead(200, [ 321cb0ef41Sopenharmony_ci 'Content-Length', '5', 331cb0ef41Sopenharmony_ci 'content-disposition', 341cb0ef41Sopenharmony_ci Buffer.from(nonUtf8Header).toString('binary'), 351cb0ef41Sopenharmony_ci ]); 361cb0ef41Sopenharmony_ci res.end('hello'); 371cb0ef41Sopenharmony_ci })); 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci server.listen(0, common.mustCall(() => { 401cb0ef41Sopenharmony_ci http.get({ port: server.address().port }, (res) => { 411cb0ef41Sopenharmony_ci assert.strictEqual(res.statusCode, 200); 421cb0ef41Sopenharmony_ci assert.strictEqual(res.headers['content-disposition'], nonUtf8ToLatin1); 431cb0ef41Sopenharmony_ci res.resume().on('end', common.mustCall(() => { 441cb0ef41Sopenharmony_ci server.close(); 451cb0ef41Sopenharmony_ci })); 461cb0ef41Sopenharmony_ci }); 471cb0ef41Sopenharmony_ci })); 481cb0ef41Sopenharmony_ci} 49