Comparing version 0.2.8 to 0.2.9
@@ -319,3 +319,3 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
options.headers['content-type'] = options.contentType; | ||
options.headers['content-length'] = data.length; | ||
options.headers['content-length'] = Buffer.byteLength(data, 'utf8'); | ||
options.headers['content-md5'] = hash.digest('base64'); | ||
@@ -322,0 +322,0 @@ } else { |
@@ -107,3 +107,3 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
data = data + '\n'; | ||
this._bytes = data.length; | ||
this._bytes = Buffer.byteLength(data, 'utf8'); | ||
if (_opts.code !== HttpCodes.NoContent) { | ||
@@ -110,0 +110,0 @@ headers['Content-Length'] = data.length; |
@@ -352,5 +352,7 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
log.trace('_parseRequest: req.body=%s', request.body); | ||
var contentLen = request.headers['content-length']; | ||
if (contentLen !== undefined) { | ||
if (parseInt(contentLen, 10) !== request.body.length) { | ||
var actualLen = Buffer.byteLength(request.body, 'utf8'); | ||
if (parseInt(contentLen, 10) !== actualLen) { | ||
return response.sendError(newError({ | ||
@@ -360,3 +362,3 @@ httpCode: HttpCodes.BadRequest, | ||
message: 'Content-Length=' + contentLen + | ||
' didn\'t match actual length=' + request.body.length | ||
' didn\'t match actual length=' + actualLen | ||
})); | ||
@@ -363,0 +365,0 @@ } |
{ | ||
"name": "restify", | ||
"description": "REST framework specifically meant for web service APIs", | ||
"version": "0.2.8", | ||
"version": "0.2.9", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
@@ -21,2 +21,4 @@ // Copyright 2011 Mark Cavage <mcavage@gmail.com> All rights reserved. | ||
exports.setUp = function(test, assert) { | ||
restify.log.level(restify.LogLevel.Trace); | ||
server = restify.createServer({ | ||
@@ -44,2 +46,3 @@ apiVersion: '1.2.3', | ||
exports.test_bad_method = function(test, assert) { | ||
@@ -181,2 +184,22 @@ var opts = common.newOptions(socket, '/test/unit'); | ||
exports.test_multibyte = function(test, assert) { | ||
var content = '\u00bd + \u00bc = \u00be'; | ||
var opts = common.newOptions(socket, '/test/' + uuid()); | ||
opts.method = 'POST'; | ||
opts.headers['Content-Type'] = 'text/plain'; | ||
opts.headers['Content-Length'] = 12; | ||
var req = http.request(opts, function(res) { | ||
common.checkResponse(assert, res); | ||
// We know the server checks content-len before | ||
// it checks content-type, so good enough. | ||
assert.equal(res.statusCode, 415); | ||
test.finish(); | ||
}); | ||
req.write(content); | ||
req.end(); | ||
}; | ||
exports.tearDown = function(test, assert) { | ||
@@ -183,0 +206,0 @@ server.on('close', function() { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
153146
3368