title: How to get net::ERR CONTENT LENGTH MISMATCH in Chrome using express
body: <p>For testing purposes I want to see in browser infamous error <code>net::ERR CONTENT LENGTH MISMATCH</code>. But the thing is I don't know how. Naïve attempt to just pass wrong <code>Content-Length</code> seems not to be working - all the clients just truncate content (btw - is it some well-established, RFC documented behavior?).</p>
  
  <p>Here's a code you can try:</p>
  
  <pre><code>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');
  });
  </code></pre>
  
  <p>The same holds true for <a href="https://gist.github.com/shabunc/65e76f4428561ee4e4fc0967b5d2be57" rel="nofollow noreferrer">minimal python server</a>.
  Also I had a crazy thought that may be <code>express</code> truncates response whenever content-length is set, but <code>tcpdump</code> clearly shows that on client side whole body is received. </p>