I want to track progress for uploading a large file which I'm chunking on the client using XHR. On my server, I take some data out of the form and persist N bytes to disk. What I'm confused about is that if I don't return the exact value that the client sent, it gets a content-length mismatch error. How does this make sense?
I send a form, with say 100 bytes and 80 of the bytes are the data I write to disk. Once I write the 80 bytes to disk, the server returns 80 for the content-length header. Why does the browser assume that I should write the same amount of bytes I sent?