I tried the following code to the find size of a xhr request.
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");
When I checked it with a sample ajax call, I got 188 bytes. But on the network console, the browser show 535 bytes.
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?