Sen req.socket.bytesRead
kullanabilir veya request-stats modülünü kullanabilirsiniz.
var requestStats = require('request-stats');
var stats = requestStats(server);
stats.on('complete', function (details) {
var size = details.req.bytes;
});
ayrıntıları şöyle görünür nesne:
{
ok: true, // `true` if the connection was closed correctly and `false` otherwise
time: 0, // The milliseconds it took to serve the request
req: {
bytes: 0, // Number of bytes sent by the client
headers: { ... }, // The headers sent by the client
method: 'POST', // The HTTP method used by the client
path: '...' // The path part of the request URL
},
res : {
bytes: 0, // Number of bytes sent back to the client
headers: { ... }, // The headers sent back to the client
status: 200 // The HTTP status code returned to the client
}
}
Yani
details.req.bytes
kadar isteği boyutu alabilirsiniz.
Başka bir seçenek req.headers['content-length']
'dir (ancak bazı istemciler bu üstbilgiyi gönderemeyebilir).
'req.headers [' content-length '] 'yeterince iyi mi? – robertklep
Awesome, bu gerçekten yeterli gibi görünüyor – Automatico