diff --git a/src/bun.js/bindings/bindings.cpp b/src/bun.js/bindings/bindings.cpp index d6049d7849..39dfe62399 100644 --- a/src/bun.js/bindings/bindings.cpp +++ b/src/bun.js/bindings/bindings.cpp @@ -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(valueCString.length()) }; diff --git a/test/js/node/test/parallel/test-http-header-obstext.js b/test/js/node/test/parallel/test-http-header-obstext.js new file mode 100644 index 0000000000..88c39cbb44 --- /dev/null +++ b/test/js/node/test/parallel/test-http-header-obstext.js @@ -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(); + })); +}); \ No newline at end of file