Bug 697689 - Fix XHR brokenness, the optimization violated a nsIStreamLisetner contract; r=jonas

This commit is contained in:
Masatoshi Kimura 2011-10-28 15:05:07 +01:00
Родитель 5d674678fa
Коммит 8f9e7ff037
1 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -1738,13 +1738,11 @@ nsXMLHttpRequest::OnDataAvailable(nsIRequest *request,
mProgressSinceLastProgressEvent = true;
bool cancelable = false;
if (mResponseType == XML_HTTP_RESPONSE_TYPE_BLOB && !mResponseBlob) {
if (CreateResponseBlob(request)) {
// We don't have to read from the local file for the blob response
mResponseBlob->GetSize(&mLoadTransferred);
ChangeState(XML_HTTP_REQUEST_LOADING);
return request->Cancel(NS_OK);
}
cancelable = CreateResponseBlob(request);
// The nsIStreamListener contract mandates us
// to read from the stream before returning.
}
PRUint32 totalRead;
@ -1752,6 +1750,13 @@ nsXMLHttpRequest::OnDataAvailable(nsIRequest *request,
(void*)this, count, &totalRead);
NS_ENSURE_SUCCESS(rv, rv);
if (cancelable) {
// We don't have to read from the local file for the blob response
mResponseBlob->GetSize(&mLoadTransferred);
ChangeState(XML_HTTP_REQUEST_LOADING);
return request->Cancel(NS_OK);
}
mLoadTransferred += totalRead;
ChangeState(XML_HTTP_REQUEST_LOADING);