Skip to content

Commit d1b39d9

Browse files
Flimmjasnell
authored andcommitted
test: add known_test request with Unicode in the URL
This test currently fails. It illustrates that Unicode in the URL does not arrive intact to the server, there is silent data corruption along the way at some point. This test is for the issue #13296. PR-URL: #13297 Reviewed-By: James M Snell <[email protected]>
1 parent 92de432 commit d1b39d9

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
// This test ensures that Unicode characters in the URL get handled correctly
5+
// by `http`
6+
// Refs: https://github.com/nodejs/node/issues/13296
7+
8+
const assert = require('assert');
9+
const http = require('http');
10+
11+
const expected = '/café🐶';
12+
13+
assert.strictEqual(
14+
expected,
15+
'/caf\u{e9}\u{1f436}',
16+
'Sanity check that string literal produced the expected string'
17+
);
18+
19+
const server = http.createServer(common.mustCall(function(req, res) {
20+
assert.strictEqual(req.url, expected);
21+
req.on('data', common.mustCall(function() {
22+
})).on('end', common.mustCall(function() {
23+
server.close();
24+
res.writeHead(200);
25+
res.end('hello world\n');
26+
}));
27+
28+
}));
29+
30+
server.listen(0, function() {
31+
http.request({
32+
port: this.address().port,
33+
path: expected,
34+
method: 'GET'
35+
}, common.mustCall(function(res) {
36+
res.resume();
37+
})).on('error', function(e) {
38+
console.log(e.message);
39+
process.exit(1);
40+
}).end();
41+
});

0 commit comments

Comments
 (0)