Bug 669049: Forgo an optimization to make responseType='blob' work on large files. r=sicking a=asa
authorKyle Huey <khuey@kylehuey.com>
Wed, 20 Jul 2011 17:29:42 -0700
changeset 70545 8d3fafa80d4b35aad49ca1de34e91773f9f457d5
parent 70544 79f80d48e0d3d76a36e284a77738ba085f0734c1
child 70546 1e49740f65a9a33066b545dc568b735d68bcbd18
child 70549 97f63a5dd9100b69056d2566a4ed225fa03b6a41
child 70552 eaacac2007f48c19cd91611863463e7e37de4405
push id1
push usersledru@mozilla.com
push dateThu, 04 Dec 2014 17:57:20 +0000
reviewerssicking, asa
bugs669049
milestone6.0
Bug 669049: Forgo an optimization to make responseType='blob' work on large files. r=sicking a=asa
content/base/src/nsXMLHttpRequest.cpp
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -1643,20 +1643,16 @@ void nsXMLHttpRequest::CreateResponseBlo
 /* void onDataAvailable (in nsIRequest request, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
 NS_IMETHODIMP
 nsXMLHttpRequest::OnDataAvailable(nsIRequest *request, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
 {
   NS_ENSURE_ARG_POINTER(inStr);
 
   NS_ABORT_IF_FALSE(mContext.get() == ctxt,"start context different from OnDataAvailable context");
 
-  if (mResponseType == XML_HTTP_RESPONSE_TYPE_BLOB && !mResponseBlob) {
-    CreateResponseBlob(request);
-  }
-
   PRUint32 totalRead;
   return inStr->ReadSegments(nsXMLHttpRequest::StreamReaderFunc, (void*)this, count, &totalRead);
 }
 
 PRBool
 IsSameOrBaseChannel(nsIRequest* aPossibleBase, nsIChannel* aChannel)
 {
   nsCOMPtr<nsIMultiPartChannel> mpChannel = do_QueryInterface(aPossibleBase);
@@ -1904,19 +1900,16 @@ nsXMLHttpRequest::OnStopRequest(nsIReque
   mReadRequest = nsnull;
   mContext = nsnull;
 
   nsCOMPtr<nsIChannel> channel(do_QueryInterface(request));
   NS_ENSURE_TRUE(channel, NS_ERROR_UNEXPECTED);
 
   if (NS_SUCCEEDED(status) && mResponseType == XML_HTTP_RESPONSE_TYPE_BLOB) {
     if (!mResponseBlob) {
-      CreateResponseBlob(request);
-    }
-    if (!mResponseBlob) {
       // Smaller files may be written in cache map instead of separate files.
       // Also, no-store response cannot be written in persistent cache.
       nsCAutoString contentType;
       mChannel->GetContentType(contentType);
       // XXX We should change mResponseBody to be a raw malloc'ed buffer
       //     to avoid copying the data.
       PRUint32 blobLen = mResponseBody.Length();
       void *blobData = PR_Malloc(blobLen);