From b4d5c7e4ceefaa2dcaa3a1945768f87dbda5f4bd Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Wed, 19 Aug 1998 23:00:15 +0000 Subject: [PATCH] RAPTOR ONLY CHECKIN network/module/nsIURL.h Added Get/Set ReloadType methods so a user can query/set the reload type for the url. The default is normal reload. network/module/nsURL.cpp Added support for the new nsIURL interface methods (Get/Set ReloadType). network/module/nsNetService.cpp OpenStream and OpenBlockingStream now query the nsIURL for it's reload type before creating the url struct. This way we can control how the url is loaded. git-svn-id: svn://10.0.0.236/trunk@8210 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/network/module/nsIURL.h | 6 +++++ mozilla/network/module/nsNetService.cpp | 32 +++++++++++++++++++++++-- mozilla/network/module/nsURL.cpp | 23 ++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/mozilla/network/module/nsIURL.h b/mozilla/network/module/nsIURL.h index 857593ab361..e8520fb7e2a 100644 --- a/mozilla/network/module/nsIURL.h +++ b/mozilla/network/module/nsIURL.h @@ -47,6 +47,8 @@ public: virtual nsresult Set(const char *aNewSpec) = 0; + virtual nsresult SetReloadType(const PRInt32 type) = 0; + /** Accessors */ //@{ /** @@ -71,7 +73,11 @@ public: /** @return ref part of the URL */ virtual PRInt32 GetPort() const = 0; + /** @return the nsISupports pointer to a container */ virtual nsISupports* GetContainer() const = 0; + + /** @return the reload type for this url */ + virtual PRInt32 GetReloadType() const = 0; //@} /** Write the URL to aString, overwriting previous contents. */ diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp index 8576474f79a..e4b3e276fd0 100644 --- a/mozilla/network/module/nsNetService.cpp +++ b/mozilla/network/module/nsNetService.cpp @@ -192,6 +192,7 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl, nsConnectionInfo *pConn; nsIProtocolConnection *pProtocol; nsresult result; + NET_ReloadMethod reloadType; if ((NULL == aConsumer) || (NULL == aUrl)) { return NS_FALSE; @@ -213,7 +214,19 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl, } /* Create the URLStruct... */ - URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD); + + /* Set the NET_ReloadMethod to correspond with what we've + * been asked to do. + * + * 0 = nsReload (normal) + * 1 = nsReloadBypassCache + * 2 = nsReloadBypassProxy + */ + if (aUrl->GetReloadType() == 1) + reloadType = NET_SUPER_RELOAD; + else + reloadType = NET_NORMAL_RELOAD; + URL_s = NET_CreateURLStruct(aUrl->GetSpec(), reloadType); if (NULL == URL_s) { pConn->Release(); return NS_FALSE; @@ -289,6 +302,8 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl, if (NULL != aUrl) { /* Create the blocking stream... */ pBlockingStream = new nsBlockingStream(); + NET_ReloadMethod reloadType; + if (NULL == pBlockingStream) { goto loser; } @@ -315,7 +330,20 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl, } /* Create the URLStruct... */ - URL_s = NET_CreateURLStruct(aUrl->GetSpec(), NET_NORMAL_RELOAD); + + /* Set the NET_ReloadMethod to correspond with what we've + * been asked to do. + * + * 0 = nsReload (normal) + * 1 = nsReloadBypassCache + * 2 = nsReloadBypassProxy + */ + if (aUrl->GetReloadType() == 1) + reloadType = NET_SUPER_RELOAD; + else + reloadType = NET_NORMAL_RELOAD; + + URL_s = NET_CreateURLStruct(aUrl->GetSpec(), reloadType); if (NULL == URL_s) { pBlockingStream->Release(); pConn->Release(); diff --git a/mozilla/network/module/nsURL.cpp b/mozilla/network/module/nsURL.cpp index 7d1d13106d4..3a46b914793 100644 --- a/mozilla/network/module/nsURL.cpp +++ b/mozilla/network/module/nsURL.cpp @@ -48,6 +48,7 @@ public: virtual PRBool operator==(const nsIURL& aURL) const; virtual nsresult Set(const char *aNewSpec); + virtual nsresult SetReloadType(const PRInt32 type); virtual const char* GetProtocol() const; virtual const char* GetHost() const; @@ -57,6 +58,7 @@ public: virtual const char* GetSpec() const; virtual PRInt32 GetPort() const; virtual nsISupports* GetContainer() const; + virtual PRInt32 GetReloadType() const; virtual void ToString(nsString& aString) const; @@ -67,6 +69,12 @@ public: char* mRef; char* mSearch; nsISupports* mContainer; + + // The reload type can be set to one of the following. + // 0 - normal reload (uses cache) (defined as nsReload in nsIWebShell.h) + // 1 - bypass the cache (defined as nsReloadBypassCache) + // 2 - bypass the proxy (not yet implemented) (defined as nsReloadBypassProxy) + PRInt32 mReloadType; PRInt32 mPort; PRBool mOK; @@ -89,6 +97,7 @@ URLImpl::URLImpl(const nsString& aSpec) mPort = -1; mSpec = nsnull; mContainer = nsnull; + mReloadType = 0; ParseURL(nsnull, aSpec); } @@ -128,6 +137,7 @@ URLImpl::URLImpl(const nsIURL* aURL, const nsString& aSpec) mPort = -1; mSpec = nsnull; mContainer = nsnull; + mReloadType = 0; ParseURL(aURL, aSpec); } @@ -181,6 +191,14 @@ nsresult URLImpl::Set(const char *aNewSpec) return ParseURL(nsnull, aNewSpec); } +nsresult URLImpl::SetReloadType(const PRInt32 type) +{ + if ( !((type >= 0) && (type <= 2)) ) + return NS_ERROR_ILLEGAL_VALUE; + mReloadType = type; + return NS_OK; +} + PRBool URLImpl::operator==(const nsIURL& aURL) const { @@ -230,6 +248,11 @@ nsISupports* URLImpl::GetContainer() const return mContainer; } +PRInt32 URLImpl::GetReloadType() const +{ + return mReloadType; +} + void URLImpl::ToString(nsString& aString) const { aString.SetLength(0);