È possibile utilizzare req.socket.bytesRead
oppure è possibile utilizzare il modulo request-stats.
var requestStats = require('request-stats');
var stats = requestStats(server);
stats.on('complete', function (details) {
var size = details.req.bytes;
});
I dettagli oggetto simile a questo:
{
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
}
}
in modo da poter ottenere la dimensione richiesta details.req.bytes
.
Un'altra opzione è req.headers['content-length']
(ma alcuni client potrebbero non inviare questa intestazione).
fonte
2015-08-30 12:07:59
'req.headers ['content-length']' abbastanza buono? – robertklep
Impressionante, sembra essere davvero abbastanza – Automatico