diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 7cb49d120e98..05c3edb926fb 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -73,6 +73,7 @@ HttpBaseChannel::HttpBaseChannel() , mInheritApplicationCache(PR_TRUE) , mChooseApplicationCache(PR_FALSE) , mLoadedFromApplicationCache(PR_FALSE) + , mChannelIsForDownload(PR_FALSE) { LOG(("Creating HttpBaseChannel @%x\n", this)); @@ -935,6 +936,20 @@ HttpBaseChannel::GetCanceled(PRBool *aCanceled) return NS_OK; } +NS_IMETHODIMP +HttpBaseChannel::GetChannelIsForDownload(PRBool *aChannelIsForDownload) +{ + *aChannelIsForDownload = mChannelIsForDownload; + return NS_OK; +} + +NS_IMETHODIMP +HttpBaseChannel::SetChannelIsForDownload(PRBool aChannelIsForDownload) +{ + mChannelIsForDownload = aChannelIsForDownload; + return NS_OK; +} + //----------------------------------------------------------------------------- // HttpBaseChannel::nsISupportsPriority //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 180018da9429..ebb523f2a787 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -165,6 +165,8 @@ public: NS_IMETHOD GetForceAllowThirdPartyCookie(PRBool *aForce); NS_IMETHOD SetForceAllowThirdPartyCookie(PRBool aForce); NS_IMETHOD GetCanceled(PRBool *aCanceled); + NS_IMETHOD GetChannelIsForDownload(PRBool *aChannelIsForDownload); + NS_IMETHOD SetChannelIsForDownload(PRBool aChannelIsForDownload); // nsISupportsPriority NS_IMETHOD GetPriority(PRInt32 *value); @@ -230,6 +232,7 @@ protected: PRUint32 mInheritApplicationCache : 1; PRUint32 mChooseApplicationCache : 1; PRUint32 mLoadedFromApplicationCache : 1; + PRUint32 mChannelIsForDownload : 1; }; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index 32a9f17c2415..a0f144298882 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -802,6 +802,12 @@ nsHttpChannel::CallOnStartRequest() rv = ApplyContentConversions(); if (NS_FAILED(rv)) return rv; + // if this channel is for a download, close off access to the cache. + if (mCacheEntry && mChannelIsForDownload) { + mCacheEntry->Doom(); + CloseCacheEntry(PR_FALSE); + } + if (!mCanceled) { // create offline cache entry if offline caching was requested if (mCacheForOfflineUse) { diff --git a/netwerk/protocol/http/nsIHttpChannelInternal.idl b/netwerk/protocol/http/nsIHttpChannelInternal.idl index e27e37388be0..a10ea3eab34b 100644 --- a/netwerk/protocol/http/nsIHttpChannelInternal.idl +++ b/netwerk/protocol/http/nsIHttpChannelInternal.idl @@ -45,7 +45,7 @@ interface nsIProxyInfo; * using any feature exposed by this interface, be aware that this interface * will change and you will be broken. You have been warned. */ -[scriptable, uuid(91dbb42a-dffc-4f47-8b27-9579c0d92c3f)] +[scriptable, uuid(9fb2a161-d075-4bf2-b07a-26bac650cc81)] interface nsIHttpChannelInternal : nsISupports { /** @@ -88,6 +88,11 @@ interface nsIHttpChannelInternal : nsISupports * Returns true iff the channel has been canceled. */ readonly attribute boolean canceled; + + /** + * Lets externalhandler tell the channel it is open on behalf of a download + */ + attribute boolean channelIsForDownload; }; [uuid(b18290f1-ff34-4e33-93a2-29aeb7b95425)] diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 501e4607f600..562534ee3c08 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -94,6 +94,7 @@ #include "nsMimeTypes.h" // used for header disposition information. #include "nsIHttpChannel.h" +#include "nsIHttpChannelInternal.h" #include "nsIEncodedChannel.h" #include "nsIMultiPartChannel.h" #include "nsIFileChannel.h" @@ -1644,6 +1645,12 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo encChannel->SetApplyConversion( applyConversion ); } + // Inform channel it is open on behalf of a download to prevent caching. + nsCOMPtr httpInternal = do_QueryInterface(aChannel); + if (httpInternal) { + httpInternal->SetChannelIsForDownload(PR_TRUE); + } + // now that the temp file is set up, find out if we need to invoke a dialog // asking the user what they want us to do with this content...