Bug 1044584 - Fix incorrect computation of mUploadTransferred. r=bz, a=lmandel
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -3589,21 +3589,23 @@ nsXMLHttpRequest::OnProgress(nsIRequest
{
// We're uploading if our state is XML_HTTP_REQUEST_OPENED or
// XML_HTTP_REQUEST_SENT
bool upload = !!((XML_HTTP_REQUEST_OPENED | XML_HTTP_REQUEST_SENT) & mState);
// When uploading, OnProgress reports also headers in aProgress and aProgressMax.
// So, try to remove the headers, if possible.
bool lengthComputable = (aProgressMax != UINT64_MAX);
if (upload) {
- mUploadTransferred = aProgress;
+ uint64_t loaded = aProgress;
if (lengthComputable) {
- mUploadTransferred = aProgressMax - mUploadTotal;
+ uint64_t headerSize = aProgressMax - mUploadTotal;
+ loaded -= headerSize;
}
mUploadLengthComputable = lengthComputable;
+ mUploadTransferred = loaded;
mProgressSinceLastProgressEvent = true;
MaybeDispatchProgressEvents(false);
} else {
mLoadLengthComputable = lengthComputable;
mLoadTotal = lengthComputable ? aProgressMax : 0;
// Don't dispatch progress events here. OnDataAvailable will take care