To check the actual length of the request, you must add it yourself. Pieces data Buffer, and they have a property .lengththat you can add.
If you specify an encoding with request.setEncoding(), your fragments datawill be String. In this case, call Buffer.byteLength(chunk)to get the length. ( Bufferis the global object in node.)
Add a total for each of your pieces and you will know how much data has been sent. Here is an example (untested):
https.createServer(function(req, res) {
var expected_length = req.headers['content-length'];
var actual_length = 0;
req.on('data', function (chunk) {
actual_length += chunk.length;
});
req.on('end', function() {
console.log('expected: ' + expected_length + ', actual: ' + actual_length);
});
});
. length Buffer, . , , chunk . , .