diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 665ce285be573a..0097a3e3b7cec6 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -136,7 +136,10 @@ struct StringPtr { Local ToString(Environment* env) const { if (str_) - return OneByteString(env->isolate(), str_, size_); + return String::NewFromUtf8(env->isolate(), + str_, + String::kNormalString, + size_); else return String::Empty(env->isolate()); } diff --git a/test/parallel/test-http-utf-incoming.js b/test/parallel/test-http-utf-incoming.js new file mode 100644 index 00000000000000..e58365902c2986 --- /dev/null +++ b/test/parallel/test-http-utf-incoming.js @@ -0,0 +1,28 @@ + +'use strict'; +var common = require('../common'); +var assert = require('assert'); + +var http = require('http'); + +var req; + +process.on('exit', function() { + assert.equal(req.url, '/?тест'); + assert.equal(req.headers['x-test'], 'тест'); +}); + + +http.createServer(function(req_, res) { + req = req_; + res.end(); + this.close(); +}).listen(common.PORT, function() { + http.request({ + port: common.PORT, + path: new Buffer('/?тест').toString('binary'), + headers: { + 'x-test': new Buffer('тест').toString('binary') + } + }).end(); +});