fix: test-http-header-obstext.js (#18371)

This commit is contained in:
Ashcon Partovi
2025-03-21 15:28:12 -07:00
committed by GitHub
parent 7b566e2cfc
commit f36d480919
2 changed files with 23 additions and 1 deletions

View File

@@ -1761,7 +1761,8 @@ void WebCore__FetchHeaders__copyTo(WebCore__FetchHeaders* headers, StringPointer
*values = { i, value.length() };
i += value.length();
} else {
ASSERT_WITH_MESSAGE(value.containsOnlyASCII(), "Header value must be ASCII. This should already be validated before calling this function.");
// HTTP headers can contain non-ASCII characters according to RFC 7230
// Non-ASCII content should be properly encoded
WTF::CString valueCString = value.utf8();
memcpy(&buf[i], valueCString.data(), valueCString.length());
*values = { i, static_cast<uint32_t>(valueCString.length()) };

View File

@@ -0,0 +1,21 @@
'use strict';
const common = require('../common');
// This test ensures that the http-parser can handle UTF-8 characters
// in the http header.
const http = require('http');
const assert = require('assert');
const server = http.createServer(common.mustCall((req, res) => {
res.end('ok');
}));
server.listen(0, () => {
http.get({
port: server.address().port,
headers: { 'Test': 'Düsseldorf' }
}, common.mustCall((res) => {
assert.strictEqual(res.statusCode, 200);
server.close();
}));
});