зеркало из https://github.com/mozilla/pjs.git
Bug 293046 XMLHttpRequest.overrideMimeType() makes loading abort for non-XML
patch by Wladimir Palant <trev@gtchat.de> r=jst sr=darin
This commit is contained in:
Родитель
eb9fb20f34
Коммит
51bce3a335
|
@ -1136,7 +1136,16 @@ nsXMLHttpRequest::StreamReaderFunc(nsIInputStream* in,
|
|||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
NS_ASSERTION(copyStream, "NS_NewByteInputStream lied");
|
||||
rv = xmlHttpRequest->mXMLParserStreamListener->OnDataAvailable(xmlHttpRequest->mReadRequest,xmlHttpRequest->mContext,copyStream,toOffset,count);
|
||||
nsresult parsingResult = xmlHttpRequest->mXMLParserStreamListener
|
||||
->OnDataAvailable(xmlHttpRequest->mReadRequest,
|
||||
xmlHttpRequest->mContext,
|
||||
copyStream, toOffset, count);
|
||||
|
||||
// No use to continue parsing if we failed here, but we
|
||||
// should still finish reading the stream
|
||||
if (NS_FAILED(parsingResult)) {
|
||||
xmlHttpRequest->mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1223,12 +1232,18 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (mOverrideMimeType.IsEmpty()) {
|
||||
// If we are not overriding the mime type, we can gain a huge
|
||||
// performance win by not even trying to parse non-XML data. This
|
||||
// also protects us from the situation where we have an XML
|
||||
// document and sink, but HTML (or other) parser, which can
|
||||
// produce unreliable results.
|
||||
nsresult status;
|
||||
request->GetStatus(&status);
|
||||
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
if (!mOverrideMimeType.IsEmpty()) {
|
||||
channel->SetContentType(mOverrideMimeType);
|
||||
}
|
||||
|
||||
// We can gain a huge performance win by not even trying to
|
||||
// parse non-XML data. This also protects us from the situation
|
||||
// where we have an XML document and sink, but HTML (or other)
|
||||
// parser, which can produce unreliable results.
|
||||
nsCAutoString type;
|
||||
channel->GetContentType(type);
|
||||
|
||||
|
@ -1236,14 +1251,8 @@ nsXMLHttpRequest::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
|
|||
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
||||
}
|
||||
} else {
|
||||
nsresult status;
|
||||
request->GetStatus(&status);
|
||||
if (NS_SUCCEEDED(status)) {
|
||||
channel->SetContentType(mOverrideMimeType);
|
||||
} else {
|
||||
// The request failed, so we shouldn't be parsing anyway
|
||||
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
||||
}
|
||||
// The request failed, so we shouldn't be parsing anyway
|
||||
mState &= ~XML_HTTP_REQUEST_PARSEBODY;
|
||||
}
|
||||
|
||||
if (mState & XML_HTTP_REQUEST_PARSEBODY) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче