From 8e801f7f380568d74c355416cff39437060d1950 Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Wed, 5 Sep 2001 03:52:26 +0000 Subject: [PATCH] Upload Channel API changes. Bug 29839. r=darin@Netscape.com, sr=rpotts@netscape.com. Also fixes bug 63408, not alerting when file-not-found. r/sr same as above git-svn-id: svn://10.0.0.236/trunk@102265 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/appstrings.properties | 1 + mozilla/docshell/base/nsDocShell.cpp | 8 +++- mozilla/docshell/base/nsWebShell.cpp | 36 +++++++++++++--- .../webBrowser/nsWebBrowserPersist.cpp | 5 ++- .../xmlextras/base/src/nsXMLHttpRequest.cpp | 6 ++- .../absync/src/nsAbSyncPostEngine.cpp | 9 ++-- .../plugin/base/src/nsPluginHostImpl.cpp | 8 +++- .../protocol/ftp/public/nsIFTPChannel.idl | 4 -- .../netwerk/protocol/ftp/src/nsFTPChannel.cpp | 22 ++++++---- .../netwerk/protocol/ftp/src/nsFTPChannel.h | 7 +++- .../protocol/http/public/nsIHttpChannel.idl | 7 +--- .../protocol/http/src/nsHttpChannel.cpp | 34 ++++++++++++++- .../netwerk/protocol/http/src/nsHttpChannel.h | 3 ++ mozilla/netwerk/test/TestUpload.cpp | 7 ++-- .../search/src/nsInternetSearchService.cpp | 41 ++++++++++--------- .../components/xfer/src/nsStreamTransfer.cpp | 6 ++- 16 files changed, 147 insertions(+), 57 deletions(-) diff --git a/mozilla/docshell/base/appstrings.properties b/mozilla/docshell/base/appstrings.properties index e68c12a9229..365b1ddcfca 100644 --- a/mozilla/docshell/base/appstrings.properties +++ b/mozilla/docshell/base/appstrings.properties @@ -17,6 +17,7 @@ # # Contributor(s): +fileNotFound=The file %s cannot be found. Please check the location and try again. dnsNotFound=%s could not be found. Please check the name and try again. protocolNotFound=%s is not a registered protocol. connectionFailure=The connection was refused when attempting to contact %s. diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 6264e435d77..170f2896922 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -66,6 +66,7 @@ #include "nsEscape.h" // Interfaces Needed +#include "nsIUploadChannel.h" #include "nsIHttpChannel.h" #include "nsIDataChannel.h" #include "nsIProgressEventSink.h" @@ -4519,7 +4520,11 @@ nsresult nsDocShell::DoURILoad(nsIURI * aURI, postDataRandomAccess->Seek(PR_SEEK_SET, 0); } - httpChannel->SetUploadStream(aPostData); + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); + + // we really need to have a content type associated with this stream!! + uploadChannel->SetUploadStream(aPostData,nsnull, -1); /* If there is a valid postdata *and* it is a History Load, * set up the cache key on the channel, to retrieve the * data only from the cache. When there is a postdata @@ -4993,6 +4998,7 @@ nsDocShell::OnNewURI(nsIURI * aURI, nsIChannel * aChannel, // Get the post data from the channel nsCOMPtr inputStream; if (aChannel) { + nsCOMPtr httpChannel(do_QueryInterface(aChannel)); if (httpChannel) { diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 2ee63c22da2..069bf2b3be0 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -108,7 +108,7 @@ typedef unsigned long HMTX; #include "nsIFileStream.h" #include "nsIHttpChannel.h" // add this to the ick include list...we need it to QI for post data interface - +#include "nsIUploadChannel.h" #include "nsILocaleService.h" #include "nsIStringBundle.h" @@ -885,12 +885,38 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, // // If the page load failed, then deal with the error condition... // Errors are handled as follows: - // 1. Send the URI to a keyword server (if enabled) - // 2. If the error was DNS failure, then add www and .com to the URI + // 1. Check to see if it a file not found error. + // 2. Send the URI to a keyword server (if enabled) + // 3. If the error was DNS failure, then add www and .com to the URI // (if appropriate). - // 3. Throw an error dialog box... + // 4. Throw an error dialog box... // + if(url && NS_FAILED(aStatus)) { + if (aStatus == NS_ERROR_FILE_NOT_FOUND) { + nsCOMPtr prompter; + nsCOMPtr stringBundle; + GetPromptAndStringBundle(getter_AddRefs(prompter), + getter_AddRefs(stringBundle)); + if (stringBundle && prompter) { + nsXPIDLString messageStr; + nsresult rv = stringBundle->GetStringFromName(NS_ConvertASCIItoUCS2("fileNotFound").get(), + getter_Copies(messageStr)); + + if (NS_SUCCEEDED(rv) && messageStr) { + nsXPIDLCString spec; + url->GetPath(getter_Copies(spec)); + + PRUnichar *msg = nsTextFormatter::smprintf(messageStr, (const char*)spec); + if (!msg) return NS_ERROR_OUT_OF_MEMORY; + + prompter->Alert(nsnull, msg); + nsTextFormatter::smprintf_free(msg); + } + } + return NS_OK; + } + nsXPIDLCString host; rv = url->GetHost(getter_Copies(host)); @@ -1109,8 +1135,8 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, nsCOMPtr httpChannel(do_QueryInterface(channel)); if(httpChannel) { - httpChannel->GetUploadStream(getter_AddRefs(inputStream)); httpChannel->GetReferrer(getter_AddRefs(referrer)); + httpChannel->GetUploadStream(getter_AddRefs(inputStream)); } } nsCOMPtr postDataRandomAccess(do_QueryInterface(inputStream)); diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp index e671097910b..76a7790bf10 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowserPersist.cpp @@ -31,6 +31,7 @@ #include "nsNetUtil.h" #include "nsIFileTransportService.h" #include "nsIHttpChannel.h" +#include "nsIUploadChannel.h" #include "nsEscape.h" #include "nsCExternalHandlerService.h" @@ -153,8 +154,10 @@ NS_IMETHODIMP nsWebBrowserPersist::SaveURI(nsIURI *aURI, nsIInputStream *aPostDa { // Rewind the postdata stream stream->Seek(PR_SEEK_SET, 0); + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); // Attach the postdata to the http channel - httpChannel->SetUploadStream(aPostData); + uploadChannel->SetUploadStream(aPostData, nsnull, -1); } } } diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index b41ce4a848d..01575547040 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -34,6 +34,7 @@ #include "nsIURI.h" #include "nsILoadGroup.h" #include "nsNetUtil.h" +#include "nsIUploadChannel.h" #include "nsIDOMSerializer.h" #include "nsISupportsPrimitives.h" #include "nsIDOMEventReceiver.h" @@ -1070,7 +1071,10 @@ nsXMLHttpRequest::Send(nsISupports *body) } if (postDataStream) { - rv = httpChannel->SetUploadStream(postDataStream); + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); + + rv = uploadChannel->SetUploadStream(postDataStream, nsnull, -1); } } diff --git a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp index 155aa123b42..974fd8015a8 100644 --- a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp +++ b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp @@ -42,6 +42,7 @@ #include "nsNetUtil.h" #include "nsMimeTypes.h" #include "nsIHttpChannel.h" +#include "nsIUploadChannel.h" #include "nsTextFormatter.h" #include "nsICookieService.h" #include "nsIAbSync.h" @@ -698,9 +699,11 @@ nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData) if (!httpChannel) return NS_ERROR_FAILURE; - if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0))) - httpChannel->SetUploadStream(postStream); - + if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, postData, 0))){ + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); + uploadChannel->SetUploadStream(postStream, nsnull, -1); + } httpChannel->AsyncOpen(this, nsnull); return NS_OK; diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 404d2bd40f7..d8bd7cda4d0 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -39,6 +39,7 @@ #include "nsIObserverService.h" #include "nsIHttpProtocolHandler.h" #include "nsIHttpChannel.h" +#include "nsIUploadChannel.h" #include "nsIByteRangeRequest.h" #include "nsIStreamListener.h" #include "nsIInputStream.h" @@ -4889,8 +4890,11 @@ NS_IMETHODIMP nsPluginHostImpl::NewPluginURLStream(const nsString& aURL, postDataRandomAccess(do_QueryInterface(postDataStream)); if (postDataRandomAccess) postDataRandomAccess->Seek(PR_SEEK_SET, 0); - - httpChannel->SetUploadStream(postDataStream); + + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); + + uploadChannel->SetUploadStream(postDataStream, nsnull, -1); if (newPostData) { diff --git a/mozilla/netwerk/protocol/ftp/public/nsIFTPChannel.idl b/mozilla/netwerk/protocol/ftp/public/nsIFTPChannel.idl index 365144b8d63..95d520b2ab4 100644 --- a/mozilla/netwerk/protocol/ftp/public/nsIFTPChannel.idl +++ b/mozilla/netwerk/protocol/ftp/public/nsIFTPChannel.idl @@ -29,10 +29,6 @@ interface nsIRequestObserver; [scriptable, uuid(3476df52-1dd2-11b2-b928-925d89b33bc0)] interface nsIFTPChannel : nsIChannel { - /** - * Set the stream to be uploaded by this channel. - */ - attribute nsIInputStream uploadStream; }; [scriptable, uuid(455d4234-0330-43d2-bbfb-99afbecbfeb0)] diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 84b5b7120bf..c96f05fb607 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -85,9 +85,10 @@ nsFTPChannel::~nsFTPChannel() if (mLock) PR_DestroyLock(mLock); } -NS_IMPL_THREADSAFE_ISUPPORTS8(nsFTPChannel, +NS_IMPL_THREADSAFE_ISUPPORTS9(nsFTPChannel, nsIChannel, nsIFTPChannel, + nsIUploadChannel, nsIRequest, nsIInterfaceRequestor, nsIProgressEventSink, @@ -656,18 +657,25 @@ nsFTPChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor *entry, return NS_OK; } - NS_IMETHODIMP -nsFTPChannel::SetUploadStream(nsIInputStream *stream) +nsFTPChannel::SetUploadStream(nsIInputStream *stream, const char *contentType, PRInt32 contentLength) { mUploadStream = stream; return NS_OK; } NS_IMETHODIMP -nsFTPChannel::GetUploadStream(nsIInputStream **stream) +nsFTPChannel::SetUploadFile(nsIFile *file, const char *contentType, PRInt32 contentLength) { - NS_IF_ADDREF(*stream = mUploadStream); - return NS_OK; -} + if (!file) return NS_ERROR_NULL_POINTER; + nsresult rv; + // Grab a file input stream + nsCOMPtr stream; + rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file); + if (NS_FAILED(rv)) + return rv; + + // set the stream on ourselves + return SetUploadStream(stream, nsnull, -1); +} diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h index 32216c2ffcc..2408b243b63 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -42,6 +42,7 @@ #include "nsIPrompt.h" #include "nsIAuthPrompt.h" #include "nsIFTPChannel.h" +#include "nsIUploadChannel.h" #include "nsICacheService.h" #include "nsICacheEntryDescriptor.h" @@ -57,6 +58,7 @@ #define FTP_CACHE_CONTROL_CONNECTION 1 class nsFTPChannel : public nsIFTPChannel, + public nsIUploadChannel, public nsIInterfaceRequestor, public nsIProgressEventSink, public nsIStreamListener, @@ -66,13 +68,14 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST NS_DECL_NSICHANNEL + NS_DECL_NSIUPLOADCHANNEL NS_DECL_NSIFTPCHANNEL NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIPROGRESSEVENTSINK NS_DECL_NSISTREAMLISTENER NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSICACHELISTENER - + // nsFTPChannel methods: nsFTPChannel(); virtual ~nsFTPChannel(); @@ -107,7 +110,7 @@ protected: PRUint32 mSourceOffset; PRInt32 mAmount; nsCOMPtr mLoadGroup; - nsCAutoString mContentType; + nsCString mContentType; PRInt32 mContentLength; nsCOMPtr mOwner; diff --git a/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl b/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl index 76c981824b3..a3bd3d3268b 100644 --- a/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl +++ b/mozilla/netwerk/protocol/http/public/nsIHttpChannel.idl @@ -61,12 +61,9 @@ interface nsIHttpChannel : nsIChannel void visitRequestHeaders(in nsIHttpHeaderVisitor visitor); /** - * Set the stream to be uploaded by this HTTP channel. Setting this causes - * the HTTP method to be changed to POST. For PUT requests, the method - * must be explicitly set. + * Get the stream (to be) uploaded by this HTTP channel. */ - attribute nsIInputStream uploadStream; - + readonly attribute nsIInputStream uploadStream; /************************************************************************** * Response info... diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp index 66fa7e73692..53a0815dd34 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -33,6 +33,8 @@ #include "nsIStringBundle.h" #include "nsISupportsPrimitives.h" #include "nsIFileStream.h" +#include "nsCExternalHandlerService.h" +#include "nsIMIMEService.h" #include "nsMimeTypes.h" #include "nsNetUtil.h" #include "nsString2.h" @@ -1555,7 +1557,7 @@ nsHttpChannel::GetCurrentPath(char **path) // nsHttpChannel::nsISupports //----------------------------------------------------------------------------- -NS_IMPL_THREADSAFE_ISUPPORTS9(nsHttpChannel, +NS_IMPL_THREADSAFE_ISUPPORTS10(nsHttpChannel, nsIRequest, nsIChannel, nsIRequestObserver, @@ -1564,6 +1566,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS9(nsHttpChannel, nsIInterfaceRequestor, nsIProgressEventSink, nsICachingChannel, + nsIUploadChannel, nsICacheListener) //----------------------------------------------------------------------------- @@ -2021,7 +2024,7 @@ nsHttpChannel::GetUploadStream(nsIInputStream **stream) } NS_IMETHODIMP -nsHttpChannel::SetUploadStream(nsIInputStream *stream) +nsHttpChannel::SetUploadStream(nsIInputStream *stream, const char* contentType, PRInt32 contentLength) { mUploadStream = stream; if (mUploadStream) @@ -2031,6 +2034,33 @@ nsHttpChannel::SetUploadStream(nsIInputStream *stream) return NS_OK; } + +NS_IMETHODIMP +nsHttpChannel::SetUploadFile(nsIFile *file, const char* contentType, PRInt32 contentLength) +{ + if (!file) return NS_ERROR_NULL_POINTER; + + nsresult rv; + // Grab a file input stream + nsCOMPtr stream; + rv = NS_NewLocalFileInputStream(getter_AddRefs(stream), file); + if (NS_FAILED(rv)) + return rv; + + // get the content type + if (contentType) + return SetUploadStream(stream, contentType, contentLength); + + nsCOMPtr MIMEService (do_GetService(NS_MIMESERVICE_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + nsXPIDLCString mimeType; + rv = MIMEService->GetTypeFromFile(file, getter_Copies(mimeType)); + if (NS_FAILED(rv)) return rv; + + // set the stream on ourselves + return SetUploadStream(stream, mimeType, contentLength); +} + NS_IMETHODIMP nsHttpChannel::GetResponseStatus(PRUint32 *value) { diff --git a/mozilla/netwerk/protocol/http/src/nsHttpChannel.h b/mozilla/netwerk/protocol/http/src/nsHttpChannel.h index 88731877a0f..c540e21685d 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpChannel.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpChannel.h @@ -38,6 +38,7 @@ #include "nsICacheEntryDescriptor.h" #include "nsICacheListener.h" #include "nsITransport.h" +#include "nsIUploadChannel.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" @@ -55,6 +56,7 @@ class nsHttpChannel : public nsIHttpChannel , public nsIInterfaceRequestor , public nsIProgressEventSink , public nsICachingChannel + , public nsIUploadChannel , public nsICacheListener { public: @@ -67,6 +69,7 @@ public: NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIPROGRESSEVENTSINK NS_DECL_NSICACHINGCHANNEL + NS_DECL_NSIUPLOADCHANNEL NS_DECL_NSICACHELISTENER nsHttpChannel(); diff --git a/mozilla/netwerk/test/TestUpload.cpp b/mozilla/netwerk/test/TestUpload.cpp index 0aae7b9b677..6c539e7a656 100644 --- a/mozilla/netwerk/test/TestUpload.cpp +++ b/mozilla/netwerk/test/TestUpload.cpp @@ -29,7 +29,7 @@ #include "nsIServiceManager.h" #include "nsNetUtil.h" -#include "nsIFTPChannel.h" +#include "nsIUploadChannel.h" static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -159,10 +159,9 @@ main(int argc, char* argv[]) rv = ioService->NewChannelFromURI(uri, getter_AddRefs(channel)); if (NS_FAILED(rv)) return rv; - // since we are testing now, we know it is a ftp url. // QI and set the upload stream - nsCOMPtr ftpChannel(do_QueryInterface(channel)); - ftpChannel->SetUploadStream(uploadStream); + nsCOMPtr uploadChannel(do_QueryInterface(channel)); + uploadChannel->SetUploadStream(uploadStream, nsnull); // create a dummy listener InputTestConsumer* listener; diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp index 56c5d13e326..b413c7ce867 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -59,6 +59,7 @@ #include "nsIChannel.h" #include "nsIFileChannel.h" #include "nsIHttpChannel.h" +#include "nsIUploadChannel.h" #include "nsIInputStream.h" #include "nsIBookmarksService.h" #include "nsIStringBundle.h" @@ -3600,27 +3601,29 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin nsCOMPtr httpChannel (do_QueryInterface(channel)); if (httpChannel) { - httpChannel->SetRequestMethod("POST"); - - // construct post data to send - nsAutoString postStr; - postStr.AssignWithConversion(POSTHEADER_PREFIX); - postStr.AppendInt(input.Length(), 10); - postStr.AppendWithConversion(POSTHEADER_SUFFIX); - postStr += input; - - nsCOMPtr postDataStream; - nsCAutoString poststrC; - poststrC.AssignWithConversion(postStr); - if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), - PR_FALSE, poststrC, 0))) - { - httpChannel->SetUploadStream(postDataStream); - } + httpChannel->SetRequestMethod("POST"); + + // construct post data to send + nsAutoString postStr; + postStr.AssignWithConversion(POSTHEADER_PREFIX); + postStr.AppendInt(input.Length(), 10); + postStr.AppendWithConversion(POSTHEADER_SUFFIX); + postStr += input; + + nsCOMPtr postDataStream; + nsCAutoString poststrC; + poststrC.AssignWithConversion(postStr); + if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postDataStream), + PR_FALSE, poststrC, 0))) + { + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); + uploadChannel->SetUploadStream(postDataStream, nsnull, -1); + } } } - - nsCOMPtr request; + + nsCOMPtr request; if (NS_SUCCEEDED(rv = channel->AsyncOpen(this, context))) { } diff --git a/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp b/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp index 395eb5ea950..7bf88ae8ef5 100644 --- a/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp +++ b/mozilla/xpfe/components/xfer/src/nsStreamTransfer.cpp @@ -31,6 +31,7 @@ #include "nsIURL.h" #include "nsEscape.h" #include "nsIHttpChannel.h" +#include "nsIUploadChannel.h" #include "nsICachingChannel.h" #include "nsIStringBundle.h" #include "nsIAllocator.h" @@ -197,7 +198,10 @@ nsStreamTransfer::SelectFileAndTransferLocationSpec( char const *aURL, nsCOMPtr stream( do_QueryInterface( postData ) ); if ( stream ) { stream->Seek( PR_SEEK_SET, 0 ); - httpChannel->SetUploadStream( postData ); + nsCOMPtr uploadChannel(do_QueryInterface(httpChannel)); + NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel"); + + uploadChannel->SetUploadStream( postData, nsnull, -1); httpChannel->SetRequestMethod("POST"); } }