From d04966eba7892e785a017b1bb67899ebb189dafb Mon Sep 17 00:00:00 2001 From: "cbiesinger%gmail.com" Date: Tue, 18 Mar 2008 19:49:20 +0000 Subject: [PATCH] bug 422537 use a storage stream instead of a pipe as the upload stream when send()ing a document, to follow the expectations of nsIUploadChannel which wants a seekable stream. r+sr=bz a=beltzner git-svn-id: svn://10.0.0.236/trunk@248118 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsXMLHttpRequest.cpp | 12 ++-- mozilla/content/base/test/Makefile.in | 1 + mozilla/content/base/test/test_bug422537.html | 55 +++++++++++++++++++ 3 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 mozilla/content/base/test/test_bug422537.html diff --git a/mozilla/content/base/src/nsXMLHttpRequest.cpp b/mozilla/content/base/src/nsXMLHttpRequest.cpp index 2e6b2ec52b1..e3225a7d88b 100644 --- a/mozilla/content/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/content/base/src/nsXMLHttpRequest.cpp @@ -88,6 +88,7 @@ #include "nsWhitespaceTokenizer.h" #include "nsIMultiPartChannel.h" #include "nsIScriptObjectPrincipal.h" +#include "nsIStorageStream.h" #define LOAD_STR "load" #define ERROR_STR "error" @@ -2134,10 +2135,12 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) // Serialize to a stream so that the encoding used will // match the document's. - nsCOMPtr input; + nsCOMPtr storStream; + rv = NS_NewStorageStream(4096, PR_UINT32_MAX, getter_AddRefs(storStream)); + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr output; - rv = NS_NewPipe(getter_AddRefs(input), getter_AddRefs(output), - 0, PR_UINT32_MAX); + rv = storStream->GetOutputStream(0, getter_AddRefs(output)); NS_ENSURE_SUCCESS(rv, rv); // Empty string for encoding means to use document's current @@ -2146,7 +2149,8 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) NS_ENSURE_SUCCESS(rv, rv); output->Close(); - postDataStream = input; + rv = storStream->NewInputStream(0, getter_AddRefs(postDataStream)); + NS_ENSURE_SUCCESS(rv, rv); } else { // nsISupportsString? nsCOMPtr wstr(do_QueryInterface(supports)); diff --git a/mozilla/content/base/test/Makefile.in b/mozilla/content/base/test/Makefile.in index 64587f7a85f..7350d7bb086 100644 --- a/mozilla/content/base/test/Makefile.in +++ b/mozilla/content/base/test/Makefile.in @@ -181,6 +181,7 @@ _TEST_FILES = test_bug5141.html \ test_bug419527.xhtml \ test_bug420609.xhtml \ test_bug420700.html \ + test_bug422537.html \ $(NULL) libs:: $(_TEST_FILES) diff --git a/mozilla/content/base/test/test_bug422537.html b/mozilla/content/base/test/test_bug422537.html new file mode 100644 index 00000000000..3867cb78087 --- /dev/null +++ b/mozilla/content/base/test/test_bug422537.html @@ -0,0 +1,55 @@ + + + + + Test for bug 422537 + + + + + + +Mozilla Bug 422537 +

+ +
+
+
+ + + +