I upload a 50 MB file into 5 MB chunks using XMLHttpRequest and Range header. Everything works fine except when I downloaded the last snippet.
Here is a screenshot of the request and response for the first fragment. Please note that the content length is 1024 * 1024 * 5 (5 MB). Also note that the server responds correctly with the first 5 MB, and in the Content-Range header sets the size of the entire file (after / ) correctly:

When I copy the response body to a text editor (Sublime), I get only 5,242,736 characters instead of the expected 5,242,880, as indicated by the Content-Length :

Why are 144 characters left? This is true for every piece that loads, although the exact difference is slightly different.
However, which is especially strange, this is the last piece. The server responds with the last ~ 2.9 MB of the file (instead of as much as 5 MB) and, apparently, correctly indicates this in the answer:

Please note that I am requesting the following 5 MB (even if it goes beyond the total file size). No biggie, the server responds with the last part of the file, and the headers indicate the actual range of bytes.
But is it really?
When I call xhr.getResponseHeader("Content-Length") with Javascript, I see a different story in Chrome:

The XMLHttpRequest object tells me that another 5 MB has been downloaded outside the file. I donβt understand something about the xhr object?
What's even weirder is that it works in Firefox 30, as expected:

Thus, between xhr.responseText.length does not match Content-Length , and these headers are not consistent between the xhr object and the network tools, I do not know what to do to fix this.
What causes these discrepancies?
Update: I confirmed that the server itself sends the request correctly, despite exceeding the Range header in the request for the last fragment. This is the result of a raw HTTP request, thanks to the nice 'ol telnet :
HTTP/1.1 206 Partial Content Server: nginx/1.4.5 Date: Mon, 14 Jul 2014 21:50:06 GMT Content-Type: application/octet-stream Content-Length: 2987360 Last-Modified: Sun, 13 Jul 2014 22:05:10 GMT Connection: keep-alive ETag: "53c30296-2fd9560" Content-Range: bytes 47185920-50173279/50173280
So, it looks like Chrome is not working properly. Should it be logged as an error? Where?