Merge mozilla-inbound to mozilla-central. a=merge
authorCosmin Sabou <csabou@mozilla.com>
Sun, 25 Nov 2018 11:47:59 +0200
changeset 504372 c48931864919
parent 504369 5120b8ce3de8 (current diff)
parent 504371 c4029bc621f5 (diff)
child 504373 def0fd8429f9
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone65.0a1
first release with
nightly linux32
c48931864919 / 65.0a1 / 20181125100116 / files
nightly linux64
c48931864919 / 65.0a1 / 20181125100116 / files
nightly mac
c48931864919 / 65.0a1 / 20181125100116 / files
nightly win32
c48931864919 / 65.0a1 / 20181125100116 / files
nightly win64
c48931864919 / 65.0a1 / 20181125100116 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-inbound to mozilla-central. a=merge
--- a/netwerk/protocol/data/nsDataChannel.cpp
+++ b/netwerk/protocol/data/nsDataChannel.cpp
@@ -3,22 +3,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // data implementation
 
 #include "nsDataChannel.h"
 
 #include "mozilla/Base64.h"
-#include "nsIOService.h"
 #include "nsDataHandler.h"
-#include "nsIPipe.h"
 #include "nsIInputStream.h"
-#include "nsIOutputStream.h"
 #include "nsEscape.h"
+#include "nsStringStream.h"
 
 using namespace mozilla;
 
 /**
  * Helper for performing a fallible unescape.
  *
  * @param aStr The string to unescape.
  * @param aBuffer Buffer to unescape into if necessary.
@@ -81,36 +79,27 @@ nsDataChannel::OpenContentStream(bool as
         // Don't allow spaces in base64-encoded content. This is only
         // relevant for escaped spaces; other spaces are stripped in
         // NewURI. We know there were no escaped spaces if the data buffer
         // wasn't used in |Unescape|.
         unescapedBuffer.StripWhitespace();
     }
 
     nsCOMPtr<nsIInputStream> bufInStream;
-    nsCOMPtr<nsIOutputStream> bufOutStream;
-
-    // create an unbounded pipe.
-    rv = NS_NewPipe(getter_AddRefs(bufInStream),
-                    getter_AddRefs(bufOutStream),
-                    net::nsIOService::gDefaultSegmentSize,
-                    UINT32_MAX,
-                    async, true);
-    if (NS_FAILED(rv))
-        return rv;
-
     uint32_t contentLen;
     if (lBase64) {
         nsAutoCString decodedData;
         rv = Base64Decode(data, decodedData);
         NS_ENSURE_SUCCESS(rv, rv);
 
-        rv = bufOutStream->Write(decodedData.get(), decodedData.Length(), &contentLen);
+        contentLen = decodedData.Length();
+        rv = NS_NewCStringInputStream(getter_AddRefs(bufInStream), decodedData);
     } else {
-        rv = bufOutStream->Write(data.Data(), data.Length(), &contentLen);
+        contentLen = data.Length();
+        rv = NS_NewCStringInputStream(getter_AddRefs(bufInStream), data);
     }
 
     if (NS_FAILED(rv))
         return rv;
 
     SetContentType(contentType);
     SetContentCharset(contentCharset);
     mContentLength = contentLen;
--- a/xpcom/io/NonBlockingAsyncInputStream.cpp
+++ b/xpcom/io/NonBlockingAsyncInputStream.cpp
@@ -173,17 +173,29 @@ NonBlockingAsyncInputStream::Close()
   return NS_OK;
 }
 
 // nsIInputStream interface
 
 NS_IMETHODIMP
 NonBlockingAsyncInputStream::Available(uint64_t* aLength)
 {
-  return mInputStream->Available(aLength);
+  nsresult rv = mInputStream->Available(aLength);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  // Nothing more to read. Let's close the stream now.
+  if (*aLength == 0) {
+    mInputStream->Close();
+    mClosed = true;
+    return NS_BASE_STREAM_CLOSED;
+  }
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 NonBlockingAsyncInputStream::Read(char* aBuffer, uint32_t aCount,
                                   uint32_t* aReadCount)
 {
   return mInputStream->Read(aBuffer, aCount, aReadCount);
 }