From ad6e1f0a3f0adf3c87c626d05678c13adfe0b712 Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Wed, 16 Sep 1998 00:40:20 +0000 Subject: [PATCH] M webshell/public/nsIDocumentLoader.h nsIDocumentLoader interface method change to LoadURL() we now accept a local ip address. M webshell/public/nsIWebShell.h 1. Extended the nsIWebShell LoadURL() method to take an additional PRUint32 parameter which represents an ip address. If specified, this address will be bound to the socket prior to connection as the local/client ip address to be used. The caller is guarantees the validity of this address. 2. Extended the nsReloadType enumeration to allow both proxy and cache bypass. M webshell/src/nsDocLoader.cpp 1. Extended nsDocumentBindInfo::Bind() to take an additional nsILoadAttribs pointer. (class definitaion change and implementation). 2. Extended nsDocLoaderImpl::LoadURL() to take an additional PRUint32 param which represents an optional local ip address to bind the connecting socket to, prior to connection. (class definitaion change and implementation) The docloader object maintains a pointer to an nsILoadAttribs interface. M webshell/src/nsWebShell.cpp Implemented new LoadURL() routine. Simple pass down to doc loader of PRUint32. M webshell/tests/ComFactory/makefile.win Added netlib to the list of prerequisites. --- docshell/base/nsWebShell.cpp | 9 ++++-- uriloader/base/nsDocLoader.cpp | 44 ++++++++++++++++++++++---- webshell/public/nsIDocumentLoader.h | 4 ++- webshell/public/nsIWebShell.h | 6 ++-- webshell/src/nsDocLoader.cpp | 44 ++++++++++++++++++++++---- webshell/src/nsWebShell.cpp | 9 ++++-- webshell/tests/ComFactory/makefile.win | 3 +- 7 files changed, 97 insertions(+), 22 deletions(-) diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index b1e02558a6e..3d0c4835ff2 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -163,7 +163,8 @@ public: NS_IMETHOD LoadURL(const PRUnichar *aURLSpec, nsIPostData* aPostData=nsnull, PRBool aModifyHistory=PR_TRUE, - nsReloadType type = nsReload); + nsReloadType aType = nsReload, + const PRUint32 localIP = 0); NS_IMETHOD Stop(void); NS_IMETHOD Reload(nsReloadType aType); @@ -1033,7 +1034,8 @@ NS_IMETHODIMP nsWebShell::LoadURL(const PRUnichar *aURLSpec, nsIPostData* aPostData, PRBool aModifyHistory, - nsReloadType type) + nsReloadType aType, + const PRUint32 aLocalIP) { nsresult rv; PRInt32 colon, fSlash; @@ -1106,7 +1108,8 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, aPostData, // Post Data nsnull, // Extra Info... this, // Observer - (PRInt32)type); // reload type + (PRInt32)aType, // reload type + aLocalIP); // load attributes. return rv; diff --git a/uriloader/base/nsDocLoader.cpp b/uriloader/base/nsDocLoader.cpp index b7608543836..c2b31f52458 100644 --- a/uriloader/base/nsDocLoader.cpp +++ b/uriloader/base/nsDocLoader.cpp @@ -39,6 +39,7 @@ #include "nsIDocumentLoadInfo.h" #include "nsVoidArray.h" #include "nsIHttpUrl.h" +#include "nsILoadAttribs.h" // XXX: Only needed for dummy factory... #include "nsIDocument.h" @@ -100,7 +101,8 @@ public: nsresult Bind(const nsString& aURLSpec, nsIPostData* aPostData, nsIStreamListener* aListener, - PRInt32 type = 0); + PRInt32 type = 0, + nsILoadAttribs* aLoadAttrib = nsnull); nsresult Stop(void); @@ -451,7 +453,8 @@ public: nsIPostData* aPostData = nsnull, nsISupports* aExtraInfo = nsnull, nsIStreamObserver* anObserver = nsnull, - PRInt32 type = 0); + PRInt32 type = 0, + const PRUint32 aLocalIP = 0); NS_IMETHOD LoadURL(const nsString& aURLSpec, nsIStreamListener* aListener); @@ -490,6 +493,8 @@ protected: nsDocLoaderImpl* mParent; nsISupportsArray* mChildDocLoaderList; nsVoidArray mObservers; + nsILoadAttribs* m_LoadAttrib; + }; @@ -501,7 +506,7 @@ nsDocLoaderImpl::nsDocLoaderImpl() NS_NewISupportsArray(&mChildDocLoaderList); mParent = nsnull; - + m_LoadAttrib = nsnull; m_DocFactory = new nsDocFactoryImpl(); NS_ADDREF(m_DocFactory); } @@ -515,6 +520,7 @@ nsDocLoaderImpl::~nsDocLoaderImpl() NS_IF_RELEASE(mChildDocLoaderList); NS_IF_RELEASE(m_LoadingDocsList); NS_IF_RELEASE(m_DocFactory); + NS_IF_RELEASE(m_LoadAttrib); } @@ -590,7 +596,8 @@ nsDocLoaderImpl::LoadURL(const nsString& aURLSpec, nsIPostData* aPostData, nsISupports* aExtraInfo, nsIStreamObserver* anObserver, - PRInt32 type) + PRInt32 type, + const PRUint32 aLocalIP) { nsresult rv; nsDocumentBindInfo* loader = nsnull; @@ -615,7 +622,27 @@ nsDocLoaderImpl::LoadURL(const nsString& aURLSpec, /* The DocumentBindInfo reference is only held by the Array... */ m_LoadingDocsList->AppendElement((nsIStreamListener *)loader); - rv = loader->Bind(aURLSpec, aPostData, nsnull, type); + // If we've got special loading instructions, mind them. + if ( (type == 2) || (type == 3) ) { + if (!m_LoadAttrib) { + rv = NS_NewLoadAttribs(&m_LoadAttrib); + if (rv != NS_OK) + return rv; + } + // type 2 and 3 correspond to proxy bypas + m_LoadAttrib->SetBypassProxy(PR_TRUE); + } + if ( aLocalIP ) { + if (!m_LoadAttrib) { + rv = NS_NewLoadAttribs(&m_LoadAttrib); + if (rv != NS_OK) + return rv; + } + + m_LoadAttrib->SetLocalIP(aLocalIP); + } + + rv = loader->Bind(aURLSpec, aPostData, nsnull, type, m_LoadAttrib); done: return rv; @@ -883,7 +910,8 @@ nsDocumentBindInfo::QueryInterface(const nsIID& aIID, nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec, nsIPostData* aPostData, nsIStreamListener* aListener, - PRInt32 type) + PRInt32 type, + nsILoadAttribs* aLoadAttrib) { nsresult rv; @@ -904,11 +932,15 @@ nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec, } } + if (aLoadAttrib) + m_Url->SetLoadAttribs(aLoadAttrib); + rv = m_Url->SetReloadType(type); if (rv != NS_OK) { return rv; } + /* Store any POST data into the URL */ if (nsnull != aPostData) { static NS_DEFINE_IID(kPostToServerIID, NS_IPOSTTOSERVER_IID); diff --git a/webshell/public/nsIDocumentLoader.h b/webshell/public/nsIDocumentLoader.h index 889ded632b2..49778731958 100644 --- a/webshell/public/nsIDocumentLoader.h +++ b/webshell/public/nsIDocumentLoader.h @@ -22,6 +22,7 @@ #include "nsweb.h" #include "prtypes.h" #include "nsISupports.h" +#include "nsILoadAttribs.h" /* Forward declarations... */ class nsString; @@ -72,7 +73,8 @@ public: nsIPostData* aPostData = nsnull, nsISupports* aExtraInfo = nsnull, nsIStreamObserver* anObserver = nsnull, - PRInt32 type = 0) = 0; + PRInt32 type = 0, + const PRUint32 aLocalIP = 0) = 0; NS_IMETHOD LoadURL(const nsString& aURLSpec, nsIStreamListener* aListener) = 0; diff --git a/webshell/public/nsIWebShell.h b/webshell/public/nsIWebShell.h index 27917f79ee0..25ec000dd60 100644 --- a/webshell/public/nsIWebShell.h +++ b/webshell/public/nsIWebShell.h @@ -78,7 +78,8 @@ public: typedef enum { nsReload, nsReloadBypassCache, - nsReloadBypassProxy + nsReloadBypassProxy, + nsReloadBypassCacheAndProxy } nsReloadType; // Return value from WillLoadURL @@ -149,7 +150,8 @@ public: NS_IMETHOD LoadURL(const PRUnichar *aURLSpec, nsIPostData* aPostData=nsnull, PRBool aModifyHistory=PR_TRUE, - nsReloadType type=nsReload) = 0; + nsReloadType aType=nsReload, + const PRUint32 aLocalIP=0) = 0; NS_IMETHOD Stop(void) = 0; NS_IMETHOD Reload(nsReloadType aType) = 0; diff --git a/webshell/src/nsDocLoader.cpp b/webshell/src/nsDocLoader.cpp index b7608543836..c2b31f52458 100644 --- a/webshell/src/nsDocLoader.cpp +++ b/webshell/src/nsDocLoader.cpp @@ -39,6 +39,7 @@ #include "nsIDocumentLoadInfo.h" #include "nsVoidArray.h" #include "nsIHttpUrl.h" +#include "nsILoadAttribs.h" // XXX: Only needed for dummy factory... #include "nsIDocument.h" @@ -100,7 +101,8 @@ public: nsresult Bind(const nsString& aURLSpec, nsIPostData* aPostData, nsIStreamListener* aListener, - PRInt32 type = 0); + PRInt32 type = 0, + nsILoadAttribs* aLoadAttrib = nsnull); nsresult Stop(void); @@ -451,7 +453,8 @@ public: nsIPostData* aPostData = nsnull, nsISupports* aExtraInfo = nsnull, nsIStreamObserver* anObserver = nsnull, - PRInt32 type = 0); + PRInt32 type = 0, + const PRUint32 aLocalIP = 0); NS_IMETHOD LoadURL(const nsString& aURLSpec, nsIStreamListener* aListener); @@ -490,6 +493,8 @@ protected: nsDocLoaderImpl* mParent; nsISupportsArray* mChildDocLoaderList; nsVoidArray mObservers; + nsILoadAttribs* m_LoadAttrib; + }; @@ -501,7 +506,7 @@ nsDocLoaderImpl::nsDocLoaderImpl() NS_NewISupportsArray(&mChildDocLoaderList); mParent = nsnull; - + m_LoadAttrib = nsnull; m_DocFactory = new nsDocFactoryImpl(); NS_ADDREF(m_DocFactory); } @@ -515,6 +520,7 @@ nsDocLoaderImpl::~nsDocLoaderImpl() NS_IF_RELEASE(mChildDocLoaderList); NS_IF_RELEASE(m_LoadingDocsList); NS_IF_RELEASE(m_DocFactory); + NS_IF_RELEASE(m_LoadAttrib); } @@ -590,7 +596,8 @@ nsDocLoaderImpl::LoadURL(const nsString& aURLSpec, nsIPostData* aPostData, nsISupports* aExtraInfo, nsIStreamObserver* anObserver, - PRInt32 type) + PRInt32 type, + const PRUint32 aLocalIP) { nsresult rv; nsDocumentBindInfo* loader = nsnull; @@ -615,7 +622,27 @@ nsDocLoaderImpl::LoadURL(const nsString& aURLSpec, /* The DocumentBindInfo reference is only held by the Array... */ m_LoadingDocsList->AppendElement((nsIStreamListener *)loader); - rv = loader->Bind(aURLSpec, aPostData, nsnull, type); + // If we've got special loading instructions, mind them. + if ( (type == 2) || (type == 3) ) { + if (!m_LoadAttrib) { + rv = NS_NewLoadAttribs(&m_LoadAttrib); + if (rv != NS_OK) + return rv; + } + // type 2 and 3 correspond to proxy bypas + m_LoadAttrib->SetBypassProxy(PR_TRUE); + } + if ( aLocalIP ) { + if (!m_LoadAttrib) { + rv = NS_NewLoadAttribs(&m_LoadAttrib); + if (rv != NS_OK) + return rv; + } + + m_LoadAttrib->SetLocalIP(aLocalIP); + } + + rv = loader->Bind(aURLSpec, aPostData, nsnull, type, m_LoadAttrib); done: return rv; @@ -883,7 +910,8 @@ nsDocumentBindInfo::QueryInterface(const nsIID& aIID, nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec, nsIPostData* aPostData, nsIStreamListener* aListener, - PRInt32 type) + PRInt32 type, + nsILoadAttribs* aLoadAttrib) { nsresult rv; @@ -904,11 +932,15 @@ nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec, } } + if (aLoadAttrib) + m_Url->SetLoadAttribs(aLoadAttrib); + rv = m_Url->SetReloadType(type); if (rv != NS_OK) { return rv; } + /* Store any POST data into the URL */ if (nsnull != aPostData) { static NS_DEFINE_IID(kPostToServerIID, NS_IPOSTTOSERVER_IID); diff --git a/webshell/src/nsWebShell.cpp b/webshell/src/nsWebShell.cpp index b1e02558a6e..3d0c4835ff2 100644 --- a/webshell/src/nsWebShell.cpp +++ b/webshell/src/nsWebShell.cpp @@ -163,7 +163,8 @@ public: NS_IMETHOD LoadURL(const PRUnichar *aURLSpec, nsIPostData* aPostData=nsnull, PRBool aModifyHistory=PR_TRUE, - nsReloadType type = nsReload); + nsReloadType aType = nsReload, + const PRUint32 localIP = 0); NS_IMETHOD Stop(void); NS_IMETHOD Reload(nsReloadType aType); @@ -1033,7 +1034,8 @@ NS_IMETHODIMP nsWebShell::LoadURL(const PRUnichar *aURLSpec, nsIPostData* aPostData, PRBool aModifyHistory, - nsReloadType type) + nsReloadType aType, + const PRUint32 aLocalIP) { nsresult rv; PRInt32 colon, fSlash; @@ -1106,7 +1108,8 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, aPostData, // Post Data nsnull, // Extra Info... this, // Observer - (PRInt32)type); // reload type + (PRInt32)aType, // reload type + aLocalIP); // load attributes. return rv; diff --git a/webshell/tests/ComFactory/makefile.win b/webshell/tests/ComFactory/makefile.win index de480d79e22..697473cec0f 100644 --- a/webshell/tests/ComFactory/makefile.win +++ b/webshell/tests/ComFactory/makefile.win @@ -73,7 +73,8 @@ LLIBS=$(LLIBS) ole32.lib LINCS=$(LINCS) -I. \ -I$(PUBLIC)\raptor \ - -I$(PUBLIC)\xpcom + -I$(PUBLIC)\xpcom \ + -I$(PUBLIC)\netlib # clobber and clobber_all will remove the following garbage: GARBAGE = $(GARBAGE) _gen