11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ci// This test ensures that Unicode characters in the URL get handled correctly
51cb0ef41Sopenharmony_ci// by `http`
61cb0ef41Sopenharmony_ci// Refs: https://github.com/nodejs/node/issues/13296
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst assert = require('assert');
91cb0ef41Sopenharmony_ciconst http = require('http');
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciconst expected = '/café�';
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciassert.strictEqual(expected, '/caf\u{e9}\u{1f436}');
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ciconst server = http.createServer(common.mustCall(function(req, res) {
161cb0ef41Sopenharmony_ci  assert.strictEqual(req.url, expected);
171cb0ef41Sopenharmony_ci  req.on('data', common.mustCall()).on('end', common.mustCall(function() {
181cb0ef41Sopenharmony_ci    server.close();
191cb0ef41Sopenharmony_ci    res.writeHead(200);
201cb0ef41Sopenharmony_ci    res.end('hello world\n');
211cb0ef41Sopenharmony_ci  }));
221cb0ef41Sopenharmony_ci
231cb0ef41Sopenharmony_ci}));
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciserver.listen(0, () => {
261cb0ef41Sopenharmony_ci  http.request({
271cb0ef41Sopenharmony_ci    port: server.address().port,
281cb0ef41Sopenharmony_ci    path: expected,
291cb0ef41Sopenharmony_ci    method: 'GET',
301cb0ef41Sopenharmony_ci  }, common.mustCall(function(res) {
311cb0ef41Sopenharmony_ci    res.resume();
321cb0ef41Sopenharmony_ci  })).on('error', function(e) {
331cb0ef41Sopenharmony_ci    console.log(e.message);
341cb0ef41Sopenharmony_ci    process.exit(1);
351cb0ef41Sopenharmony_ci  }).end();
361cb0ef41Sopenharmony_ci});
37