From d1b39d92d663b14605a2e73c64fe6a13466ca727 Mon Sep 17 00:00:00 2001 From: David D Lowe Date: Tue, 30 May 2017 14:08:16 +0100 Subject: [PATCH] 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 https://github.com/nodejs/node/issues/13296. PR-URL: https://github.com/nodejs/node/pull/13297 Reviewed-By: James M Snell --- .../test-http-path-contains-unicode.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 test/known_issues/test-http-path-contains-unicode.js diff --git a/test/known_issues/test-http-path-contains-unicode.js b/test/known_issues/test-http-path-contains-unicode.js new file mode 100644 index 00000000000000..8f90a0d57f07b4 --- /dev/null +++ b/test/known_issues/test-http-path-contains-unicode.js @@ -0,0 +1,41 @@ +'use strict'; +const common = require('../common'); + +// This test ensures that Unicode characters in the URL get handled correctly +// by `http` +// Refs: https://github.com/nodejs/node/issues/13296 + +const assert = require('assert'); +const http = require('http'); + +const expected = '/café🐶'; + +assert.strictEqual( + expected, + '/caf\u{e9}\u{1f436}', + 'Sanity check that string literal produced the expected string' +); + +const server = http.createServer(common.mustCall(function(req, res) { + assert.strictEqual(req.url, expected); + req.on('data', common.mustCall(function() { + })).on('end', common.mustCall(function() { + server.close(); + res.writeHead(200); + res.end('hello world\n'); + })); + +})); + +server.listen(0, function() { + http.request({ + port: this.address().port, + path: expected, + method: 'GET' + }, common.mustCall(function(res) { + res.resume(); + })).on('error', function(e) { + console.log(e.message); + process.exit(1); + }).end(); +});