title: How browser calculates size of xhr request
body: <p>I tried the following code to the find size of a xhr request.</p>
  
  <pre><code>var request = new XMLHttpRequest();
  request.open('GET', 'authenticate.json', false);
  request.send();
  var size = request.getAllResponseHeaders().toLowerCase().match(/content-length: \d+/);
  console.log(size + " bytes");
  </code></pre>
  
  <p>When I checked it with a sample ajax call, I got 188 bytes. But on the network console, the browser show 535 bytes.</p>
  
  <p><img src="https://i.stack.imgur.com/yK7ej.jpg" alt="enter image description here"></p>
  
  <p>How is the browser calculating the size of an xhr request? Is that a content length or some this else? How can I find the size using javascript instead of finding content length?</p>