diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 5680ca9265a..b16e1475f57 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -50,6 +50,7 @@ #include "nsIAuthPrompt.h" #include "nsTextFormatter.h" #include "nsIHttpEventSink.h" +#include "nsIUploadChannel.h" #include "nsISecurityEventSink.h" #include "nsScriptSecurityManager.h" #include "nsDocumentCharsetInfoCID.h" @@ -5643,7 +5644,9 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, } if (httpChannel) { - httpChannel->GetUploadStream(getter_AddRefs(inputStream)); + nsCOMPtr uploadChannel(do_QueryInterface(channel)); + if (uploadChannel) { + httpChannel->GetUploadStream(getter_AddRefs(inputStream)); } } /* Create SH Entry (mLSHE) only if there is a SessionHistory object (mSessionHistory) in diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 021c13c29e9..29f3a4f5f3d 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -117,7 +117,8 @@ typedef unsigned long HMTX; #include "nsIFileStream.h" #include "nsISHistoryInternal.h" -#include "nsIHttpChannel.h" // add this to the ick include list...we need it to QI for post data interface +#include "nsIHttpChannel.h" +#include "nsIUploadChannel.h" #include "nsILocaleService.h" #include "nsIStringBundle.h" @@ -1047,7 +1048,10 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, if(httpChannel) { httpChannel->GetReferrer(getter_AddRefs(referrer)); - httpChannel->GetUploadStream(getter_AddRefs(inputStream)); + nsCOMPtr uploadChannel(do_QueryInterface(channel)); + if (uploadChannel) { + httpChannel->GetUploadStream(getter_AddRefs(inputStream)); + } } } nsCOMPtr postDataSeekable(do_QueryInterface(inputStream)); diff --git a/mozilla/netwerk/base/public/nsIUploadChannel.idl b/mozilla/netwerk/base/public/nsIUploadChannel.idl index b5dd022a85c..2be23357952 100644 --- a/mozilla/netwerk/base/public/nsIUploadChannel.idl +++ b/mozilla/netwerk/base/public/nsIUploadChannel.idl @@ -40,6 +40,10 @@ interface nsIInputStream; interface nsIChannel; interface nsIFile; +// Notes: +// Do we want to have expose contentType and contentLength? +// What about a getter for the nsIFile? + [scriptable, uuid(ddf633d8-e9a4-439d-ad88-de636fd9bb75)] interface nsIUploadChannel : nsISupports { @@ -77,6 +81,13 @@ interface nsIUploadChannel : nsISupports * Use of -1 assumes that the data length is returned by nsIFile::fileSize */ void setUploadFile(in nsIFile file, in string contentType, in long contentLength); + + /** + * Get the stream (to be) uploaded by this channel. This may return null if + * setUploadFile was called. + */ + readonly attribute nsIInputStream uploadStream; + }; diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index be1e3a46d83..4c38de2ae1a 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -783,4 +783,13 @@ nsFileChannel::SetUploadFile(nsIFile *aFile, return SetUploadStream(inStream, aContentType, aContentLength); } +NS_IMETHODIMP +nsFileChannel::GetUploadStream(nsIInputStream **stream) +{ + NS_ENSURE_ARG_POINTER(stream); + *stream = mUploadStream; + NS_IF_ADDREF(*stream); + return NS_OK; +} + //////////////////////////////////////////////////////////////////////////////// diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 4422411e345..038a0009b42 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -741,6 +741,15 @@ nsFTPChannel::SetUploadFile(nsIFile *file, const char *contentType, PRInt32 cont return SetUploadStream(stream, nsnull, -1); } +NS_IMETHODIMP +nsFTPChannel::GetUploadStream(nsIInputStream **stream) +{ + NS_ENSURE_ARG_POINTER(stream); + *stream = mUploadStream; + NS_IF_ADDREF(*stream); + return NS_OK; +} + NS_IMETHODIMP nsFTPChannel::SetListFormat(PRUint32 format) { if (format != FORMAT_PREF && diff --git a/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl index 7a9c65ba28d..1a961c73c56 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl @@ -66,11 +66,6 @@ interface nsIHttpChannel : nsIChannel void setRequestHeader(in ACString header, in ACString value); void visitRequestHeaders(in nsIHttpHeaderVisitor visitor); - /** - * Get the stream (to be) uploaded by this HTTP channel. - */ - readonly attribute nsIInputStream uploadStream; - /************************************************************************** * Response info... */ diff --git a/mozilla/netwerk/protocol/http/src/nsHttpDigestAuth.cpp b/mozilla/netwerk/protocol/http/src/nsHttpDigestAuth.cpp index 58d6b159c55..afc2fcdd9be 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpDigestAuth.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpDigestAuth.cpp @@ -161,7 +161,9 @@ nsHttpDigestAuth::GenerateCredentials(nsIHttpChannel *httpChannel, if (http_channel != nsnull) { nsIInputStream * upload; - http_channel->GetUploadStream(&upload); + nsCOMPtr uc = do_QueryInterface(http_channel); + NS_ENSURE_TRUE(uc, NS_ERROR_UNEXPECTED); + uc->GetUploadStream(&upload); if (upload) { char * upload_buffer; int upload_buffer_length = 0;