For testing purposes I want to see in browser infamous error net::ERR CONTENT LENGTH MISMATCH
. But the thing is I don't know how. Naïve attempt to just pass wrong Content-Length
seems not to be working - all the clients just truncate content (btw - is it some well-established, RFC documented behavior?).
Here's a code you can try:
var express = require('express');
var app = express();
app.get('/ping', function (req, res) {
res.set({
'Content-Length': 7,
});
// don't use res.send,
//it will ignore explicitly set Content-Length in favor of the right one
res.write('ABCDEFGHIJKLMNOP');
res.end();
})
app.listen(3000, function () {
console.log('http://127.0.0.1:3000');
});
The same holds true for minimal python server.
Also I had a crazy thought that may be express
truncates response whenever content-length is set, but tcpdump
clearly shows that on client side whole body is received.