From 5a2d9f0d2d819159f366347e96acd2b92415164b Mon Sep 17 00:00:00 2001 From: "darin%netscape.com" Date: Thu, 13 Sep 2001 02:21:05 +0000 Subject: [PATCH] checking bbaetz's patch for bug 89500 "SOCKS: only http|https re-directted in (post Mozilla 0.9.2)" patch=bbaetz, r=dougt, sr=darin --- chrome/src/nsChromeProtocolHandler.cpp | 2 +- .../xpcom/base/src/nsLDAPProtocolHandler.cpp | 4 +- docshell/base/appstrings.properties | 1 + dom/src/jsurl/nsJSProtocolHandler.cpp | 2 +- extensions/datetime/nsDateTimeChannel.cpp | 28 ++-- extensions/datetime/nsDateTimeChannel.h | 7 +- extensions/datetime/nsDateTimeHandler.cpp | 17 +- extensions/datetime/nsDateTimeHandler.h | 5 +- extensions/finger/nsFingerChannel.cpp | 7 +- extensions/finger/nsFingerChannel.h | 4 +- extensions/finger/nsFingerHandler.cpp | 17 +- extensions/finger/nsFingerHandler.h | 7 +- .../base/src/inBitmapProtocolHandler.cpp | 2 +- extensions/irc/js/lib/chatzilla-service.js | 5 +- extensions/irc/js/lib/connection-xpcom.js | 16 +- layout/html/forms/src/nsFormFrame.cpp | 4 - .../addrbook/src/nsAddbookProtocolHandler.cpp | 2 +- mailnews/base/util/nsMsgProtocol.cpp | 2 +- mailnews/compose/src/nsSmtpService.cpp | 2 +- mailnews/imap/src/nsImapProtocol.cpp | 4 +- mailnews/imap/src/nsImapService.cpp | 2 +- mailnews/local/src/nsMailboxService.cpp | 2 +- mailnews/local/src/nsPop3Service.cpp | 2 +- mailnews/news/src/nsNntpService.cpp | 2 +- modules/libjar/nsJARProtocolHandler.cpp | 2 +- .../decoders/icon/nsIconProtocolHandler.cpp | 2 +- modules/plugin/base/src/nsPluginHostImpl.cpp | 30 ++-- netwerk/base/public/MANIFEST_IDL | 2 + netwerk/base/public/Makefile.in | 2 + netwerk/base/public/makefile.win | 2 + netwerk/base/public/nsIIOService.idl | 6 +- netwerk/base/public/nsIProtocolHandler.idl | 23 ++- .../base/public/nsIProtocolProxyService.idl | 8 +- .../base/public/nsIProxiedProtocolHandler.idl | 38 +++++ netwerk/base/public/nsIProxyInfo.idl | 42 +++++ .../base/public/nsISocketTransportService.idl | 26 +-- netwerk/base/public/nsNetUtil.h | 14 ++ netwerk/base/src/nsIOService.cpp | 49 +++--- netwerk/base/src/nsProtocolProxyService.cpp | 152 +++++++++++------- netwerk/base/src/nsProtocolProxyService.h | 31 ++++ netwerk/base/src/nsProxyAutoConfig.js | 2 +- netwerk/base/src/nsSocketTransport.cpp | 48 ++++-- netwerk/base/src/nsSocketTransport.h | 6 +- netwerk/base/src/nsSocketTransportService.cpp | 37 ++--- .../about/src/nsAboutProtocolHandler.cpp | 2 +- netwerk/protocol/data/src/nsDataHandler.cpp | 2 +- .../datetime/src/nsDateTimeChannel.cpp | 28 ++-- .../protocol/datetime/src/nsDateTimeChannel.h | 7 +- .../datetime/src/nsDateTimeHandler.cpp | 17 +- .../protocol/datetime/src/nsDateTimeHandler.h | 5 +- .../file/src/nsFileProtocolHandler.cpp | 2 +- .../protocol/finger/src/nsFingerChannel.cpp | 7 +- netwerk/protocol/finger/src/nsFingerChannel.h | 4 +- .../protocol/finger/src/nsFingerHandler.cpp | 17 +- netwerk/protocol/finger/src/nsFingerHandler.h | 7 +- netwerk/protocol/ftp/src/nsFTPChannel.cpp | 6 +- netwerk/protocol/ftp/src/nsFTPChannel.h | 7 +- .../ftp/src/nsFtpConnectionThread.cpp | 13 +- .../protocol/ftp/src/nsFtpConnectionThread.h | 5 +- .../ftp/src/nsFtpControlConnection.cpp | 5 +- .../protocol/ftp/src/nsFtpControlConnection.h | 4 +- .../protocol/ftp/src/nsFtpProtocolHandler.cpp | 16 +- .../protocol/ftp/src/nsFtpProtocolHandler.h | 5 +- .../protocol/gopher/src/nsGopherChannel.cpp | 11 +- netwerk/protocol/gopher/src/nsGopherChannel.h | 4 +- .../protocol/gopher/src/nsGopherHandler.cpp | 19 ++- netwerk/protocol/gopher/src/nsGopherHandler.h | 5 +- .../http/public/nsIHttpProtocolHandler.idl | 17 +- netwerk/protocol/http/src/nsHttpChannel.cpp | 32 ++-- netwerk/protocol/http/src/nsHttpChannel.h | 7 +- .../protocol/http/src/nsHttpConnection.cpp | 39 ++--- netwerk/protocol/http/src/nsHttpConnection.h | 59 +++---- netwerk/protocol/http/src/nsHttpHandler.cpp | 39 +++-- netwerk/protocol/http/src/nsHttpHandler.h | 1 + .../protocol/jar/src/nsJARProtocolHandler.cpp | 2 +- .../keyword/src/nsKeywordProtocolHandler.cpp | 2 +- .../protocol/res/src/nsResProtocolHandler.cpp | 2 +- netwerk/protocol/theme/src/nsThemeHandler.cpp | 2 +- .../viewsource/src/nsViewSourceHandler.cpp | 2 +- netwerk/test/Makefile.in | 1 - netwerk/test/TestSocketIO.cpp | 2 +- netwerk/test/TestSocketInput.cpp | 2 +- netwerk/test/TestSocketTransport.cpp | 2 +- rdf/chrome/src/nsChromeProtocolHandler.cpp | 2 +- .../exthandler/nsExternalProtocolHandler.cpp | 2 +- xpinstall/src/nsXPInstallManager.cpp | 2 + 86 files changed, 686 insertions(+), 397 deletions(-) create mode 100644 netwerk/base/public/nsIProxiedProtocolHandler.idl create mode 100644 netwerk/base/public/nsIProxyInfo.idl diff --git a/chrome/src/nsChromeProtocolHandler.cpp b/chrome/src/nsChromeProtocolHandler.cpp index 5aa309d4c7b7..fc0cc58be90d 100644 --- a/chrome/src/nsChromeProtocolHandler.cpp +++ b/chrome/src/nsChromeProtocolHandler.cpp @@ -525,7 +525,7 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re } NS_IMETHODIMP -nsChromeProtocolHandler::GetURIType(PRInt16 *result) +nsChromeProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_STD; return NS_OK; diff --git a/directory/xpcom/base/src/nsLDAPProtocolHandler.cpp b/directory/xpcom/base/src/nsLDAPProtocolHandler.cpp index b0e307f1faef..4b72f49735e4 100644 --- a/directory/xpcom/base/src/nsLDAPProtocolHandler.cpp +++ b/directory/xpcom/base/src/nsLDAPProtocolHandler.cpp @@ -77,10 +77,10 @@ nsLDAPProtocolHandler::GetDefaultPort(PRInt32 *result) return NS_OK; } -// getter method for uritype attribute +// getter method for protocol flags attribute // NS_IMETHODIMP -nsLDAPProtocolHandler::GetURIType(PRInt16 *result) +nsLDAPProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE; return NS_OK; diff --git a/docshell/base/appstrings.properties b/docshell/base/appstrings.properties index 365b1ddcfcad..fec46f2a7d16 100644 --- a/docshell/base/appstrings.properties +++ b/docshell/base/appstrings.properties @@ -24,3 +24,4 @@ connectionFailure=The connection was refused when attempting to contact %s. netTimeout=The operation timed out when attempting to contact %s. repost=The page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel. repostConfirm=The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel. +fileNotFound=%s does not exist or could not be accessed. Please check the file path and try again. diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp index bcdc4156d433..9585e5fff34e 100644 --- a/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -716,7 +716,7 @@ nsJSProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsJSProtocolHandler::GetURIType(PRInt16 *result) +nsJSProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; diff --git a/extensions/datetime/nsDateTimeChannel.cpp b/extensions/datetime/nsDateTimeChannel.cpp index c99ff7c547ee..46fb4f81f059 100644 --- a/extensions/datetime/nsDateTimeChannel.cpp +++ b/extensions/datetime/nsDateTimeChannel.cpp @@ -33,8 +33,6 @@ #include "nsITransport.h" #include "nsIProgressEventSink.h" -static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); - // nsDateTimeChannel methods nsDateTimeChannel::nsDateTimeChannel() { NS_INIT_REFCNT(); @@ -52,13 +50,14 @@ NS_IMPL_ISUPPORTS4(nsDateTimeChannel, nsIRequestObserver) nsresult -nsDateTimeChannel::Init(nsIURI* uri) +nsDateTimeChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) { nsresult rv; NS_ASSERTION(uri, "no uri"); mUrl = uri; + mProxyInfo = proxyInfo; rv = mUrl->GetPort(&mPort); if (NS_FAILED(rv) || mPort < 1) @@ -163,12 +162,17 @@ nsDateTimeChannel::Open(nsIInputStream **_retval) if (NS_FAILED(rv)) return rv; - nsCOMPtr socketService = - do_GetService(kSocketTransportServiceCID, &rv); + nsCOMPtr sts = + do_GetService("@mozilla.org/network/socket-transport-service;1", &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); + rv = sts->CreateTransport(mHost, + mPort, + mProxyInfo, + 32, + 32, + getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; transport->SetNotificationCallbacks(mCallbacks, @@ -185,12 +189,17 @@ nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) if (NS_FAILED(rv)) return rv; - nsCOMPtr socketService = - do_GetService(kSocketTransportServiceCID, &rv); + nsCOMPtr sts = + do_GetService("@mozilla.org/network/socket-transport-service;1", &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); + rv = sts->CreateTransport(mHost, + mPort, + mProxyInfo, + 32, + 32, + getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; transport->SetNotificationCallbacks(mCallbacks, @@ -334,4 +343,3 @@ nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext, mContentLength = aLength; return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength); } - diff --git a/extensions/datetime/nsDateTimeChannel.h b/extensions/datetime/nsDateTimeChannel.h index b7118239f65d..636fcf022482 100644 --- a/extensions/datetime/nsDateTimeChannel.h +++ b/extensions/datetime/nsDateTimeChannel.h @@ -38,7 +38,7 @@ #include "nsIURI.h" #include "nsDateTimeHandler.h" #include "nsIStreamListener.h" - +#include "nsIProxyInfo.h" class nsDateTimeChannel : public nsIChannel, @@ -59,7 +59,7 @@ public: static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); - nsresult Init(nsIURI* uri); + nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo); protected: nsCOMPtr mCallbacks; @@ -70,7 +70,8 @@ protected: nsCOMPtr mLoadGroup; nsCString mContentType; PRInt32 mContentLength; - nsCOMPtr mOwner; + nsCOMPtr mOwner; + nsCOMPtr mProxyInfo; PRInt32 mPort; nsXPIDLCString mHost; diff --git a/extensions/datetime/nsDateTimeHandler.cpp b/extensions/datetime/nsDateTimeHandler.cpp index 1a1ebf48cf09..8e774e6461d4 100644 --- a/extensions/datetime/nsDateTimeHandler.cpp +++ b/extensions/datetime/nsDateTimeHandler.cpp @@ -43,7 +43,9 @@ nsDateTimeHandler::nsDateTimeHandler() { nsDateTimeHandler::~nsDateTimeHandler() { } -NS_IMPL_ISUPPORTS1(nsDateTimeHandler, nsIProtocolHandler) +NS_IMPL_ISUPPORTS2(nsDateTimeHandler, + nsIProtocolHandler, + nsIProxiedProtocolHandler) NS_METHOD nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { @@ -74,8 +76,8 @@ nsDateTimeHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsDateTimeHandler::GetURIType(PRInt16 *result) { - *result = URI_NORELATIVE | URI_NOAUTH; +nsDateTimeHandler::GetProtocolFlags(PRUint32 *result) { + *result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY; return NS_OK; } @@ -104,6 +106,13 @@ nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, NS_IMETHODIMP nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result) +{ + return NewProxiedChannel(url, nsnull, result); +} + +NS_IMETHODIMP +nsDateTimeHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, + nsIChannel* *result) { nsresult rv; @@ -111,7 +120,7 @@ nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result) rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel); if (NS_FAILED(rv)) return rv; - rv = channel->Init(url); + rv = channel->Init(url, proxyInfo); if (NS_FAILED(rv)) { NS_RELEASE(channel); return rv; diff --git a/extensions/datetime/nsDateTimeHandler.h b/extensions/datetime/nsDateTimeHandler.h index 9737e5525f7e..7cb99d113bd7 100644 --- a/extensions/datetime/nsDateTimeHandler.h +++ b/extensions/datetime/nsDateTimeHandler.h @@ -26,7 +26,7 @@ #ifndef nsDateTimeHandler_h___ #define nsDateTimeHandler_h___ -#include "nsIProtocolHandler.h" +#include "nsIProxiedProtocolHandler.h" #define DATETIME_PORT 13 @@ -34,11 +34,12 @@ #define NS_DATETIMEHANDLER_CID \ { 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } } -class nsDateTimeHandler : public nsIProtocolHandler +class nsDateTimeHandler : public nsIProxiedProtocolHandler { public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER // nsDateTimeHandler methods: nsDateTimeHandler(); diff --git a/extensions/finger/nsFingerChannel.cpp b/extensions/finger/nsFingerChannel.cpp index 7e6898a56b9d..dffeae8ed5a3 100644 --- a/extensions/finger/nsFingerChannel.cpp +++ b/extensions/finger/nsFingerChannel.cpp @@ -62,7 +62,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel, nsIRequestObserver) nsresult -nsFingerChannel::Init(nsIURI* uri) +nsFingerChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) { nsresult rv; nsXPIDLCString autoBuffer; @@ -70,6 +70,7 @@ nsFingerChannel::Init(nsIURI* uri) NS_ASSERTION(uri, "no uri"); mUrl = uri; + mProxyInfo = proxyInfo; // For security reasons, we do not allow the user to specify a // non-default port for finger: URL's. @@ -197,7 +198,7 @@ nsFingerChannel::Open(nsIInputStream **_retval) do_GetService(kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, + rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE, BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; @@ -220,7 +221,7 @@ nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) do_GetService(kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, + rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE, BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; diff --git a/extensions/finger/nsFingerChannel.h b/extensions/finger/nsFingerChannel.h index 9086ec00aa17..cd95b1033926 100644 --- a/extensions/finger/nsFingerChannel.h +++ b/extensions/finger/nsFingerChannel.h @@ -35,6 +35,7 @@ #include "nsFingerHandler.h" #include "nsIStreamListener.h" #include "nsITransport.h" +#include "nsIProxyInfo.h" class nsFingerChannel : public nsIChannel, @@ -55,7 +56,7 @@ public: static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); - nsresult Init(nsIURI* uri); + nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo); protected: nsCOMPtr mCallbacks; @@ -80,6 +81,7 @@ protected: nsCOMPtr mResponseContext; nsCOMPtr mTransport; nsCOMPtr mTransportRequest; + nsCOMPtr mProxyInfo; nsresult mStatus; protected: diff --git a/extensions/finger/nsFingerHandler.cpp b/extensions/finger/nsFingerHandler.cpp index 3a61fd1fe1ca..dd4012bfca3b 100644 --- a/extensions/finger/nsFingerHandler.cpp +++ b/extensions/finger/nsFingerHandler.cpp @@ -43,7 +43,9 @@ nsFingerHandler::nsFingerHandler() { nsFingerHandler::~nsFingerHandler() { } -NS_IMPL_ISUPPORTS1(nsFingerHandler, nsIProtocolHandler) +NS_IMPL_ISUPPORTS2(nsFingerHandler, + nsIProtocolHandler, + nsIProxiedProtocolHandler) NS_METHOD nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { @@ -74,8 +76,8 @@ nsFingerHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsFingerHandler::GetURIType(PRInt16 *result) { - *result = URI_NORELATIVE | URI_NOAUTH; +nsFingerHandler::GetProtocolFlags(PRUint32 *result) { + *result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY; return NS_OK; } @@ -104,6 +106,13 @@ nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, NS_IMETHODIMP nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result) +{ + return NewProxiedChannel(url, nsnull, result); +} + +NS_IMETHODIMP +nsFingerHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, + nsIChannel* *result) { nsresult rv; @@ -111,7 +120,7 @@ nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result) rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel); if (NS_FAILED(rv)) return rv; - rv = channel->Init(url); + rv = channel->Init(url, proxyInfo); if (NS_FAILED(rv)) { NS_RELEASE(channel); return rv; diff --git a/extensions/finger/nsFingerHandler.h b/extensions/finger/nsFingerHandler.h index 9d07996889d0..367999686b97 100644 --- a/extensions/finger/nsFingerHandler.h +++ b/extensions/finger/nsFingerHandler.h @@ -26,7 +26,9 @@ #ifndef nsFingerHandler_h___ #define nsFingerHandler_h___ -#include "nsIProtocolHandler.h" +#include "nsIProxiedProtocolHandler.h" + +class nsIProxyInfo; #define FINGER_PORT 79 @@ -35,11 +37,12 @@ { 0x76d6d5d8, 0x1dd2, 0x11b2, \ {0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} } -class nsFingerHandler : public nsIProtocolHandler +class nsFingerHandler : public nsIProxiedProtocolHandler { public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER // nsFingerHandler methods: nsFingerHandler(); diff --git a/extensions/inspector/base/src/inBitmapProtocolHandler.cpp b/extensions/inspector/base/src/inBitmapProtocolHandler.cpp index d58c890f1f4c..64dbead2e792 100644 --- a/extensions/inspector/base/src/inBitmapProtocolHandler.cpp +++ b/extensions/inspector/base/src/inBitmapProtocolHandler.cpp @@ -59,7 +59,7 @@ NS_IMETHODIMP inBitmapProtocolHandler::GetDefaultPort(PRInt32 *result) return NS_OK; } -NS_IMETHODIMP inBitmapProtocolHandler::GetURIType(PRInt16 *result) +NS_IMETHODIMP inBitmapProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE; return NS_OK; diff --git a/extensions/irc/js/lib/chatzilla-service.js b/extensions/irc/js/lib/chatzilla-service.js index 5bf70192e467..36532fbcbce6 100644 --- a/extensions/irc/js/lib/chatzilla-service.js +++ b/extensions/irc/js/lib/chatzilla-service.js @@ -163,8 +163,9 @@ function IRCProtocolHandler() IRCProtocolHandler.prototype.scheme = "irc"; IRCProtocolHandler.prototype.defaultPort = 6667; -IRCProtocolHandler.prototype.URIType = - Components.interfaces.nsIProtocolHandler.URI_NORELATIVE; +IRCProtocolHandler.prototype.protocolFlags = + nsIProtocolHandler.URI_NORELATIVE | + nsIProtocolHandler.ALLOWS_PROXY; IRCProtocolHandler.prototype.allowPort = function (aPort, aScheme) diff --git a/extensions/irc/js/lib/connection-xpcom.js b/extensions/irc/js/lib/connection-xpcom.js index 84a317a62453..b24998008f20 100644 --- a/extensions/irc/js/lib/connection-xpcom.js +++ b/extensions/irc/js/lib/connection-xpcom.js @@ -79,7 +79,21 @@ function bc_connect(host, port, bind, tcp_flag, observer) this.bind = bind; this.tcp_flag = tcp_flag; - this._transport = this._sockService.createTransport (host, port, null, -1, + // Lets get a transportInfo for this + var pps = Components.classes["@mozilla.org/network/protocol-proxy-service;1"]. + getService(). + QueryInterface(Components.interfaces.nsIProtocolProxyService); + + if (!pps) + throw ("Couldn't get protocol proxy service"); + + var uri = Components.classes["@mozilla.org/network/simple-uri;1"]. + createInstance(Components.interfaces.nsIURI); + uri.spec = "irc:" + host + ':' + port; + + var info = pps.examineForProxy(uri); + + this._transport = this._sockService.createTransport (host, port, info, 0, 0); if (!this._transport) throw ("Error creating transport."); diff --git a/layout/html/forms/src/nsFormFrame.cpp b/layout/html/forms/src/nsFormFrame.cpp index a5c6d54b4ba8..02364799466d 100644 --- a/layout/html/forms/src/nsFormFrame.cpp +++ b/layout/html/forms/src/nsFormFrame.cpp @@ -1273,10 +1273,6 @@ nsresult nsFormFrame::ProcessAsURLEncoded(nsIFormProcessor* aFormProcessor, PRBo aData.AppendWithConversion(CRLF); } aData += buf; - // Need to append CRLF to end of stream for compatability with Nav and IE - if (isPost) { - aData.AppendWithConversion(CRLF); - } return rv; } diff --git a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp index de77621a849d..35330843aa99 100644 --- a/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp +++ b/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp @@ -94,7 +94,7 @@ NS_IMETHODIMP nsAddbookProtocolHandler::GetDefaultPort(PRInt32 *aDefaultPort) return NS_OK; } -NS_IMETHODIMP nsAddbookProtocolHandler::GetURIType(PRInt16 *aUritype) +NS_IMETHODIMP nsAddbookProtocolHandler::GetProtocolFlags(PRUint32 *aUritype) { *aUritype = URI_STD; return NS_OK; diff --git a/mailnews/base/util/nsMsgProtocol.cpp b/mailnews/base/util/nsMsgProtocol.cpp index 94c3d6959c02..70f3603e8f9a 100644 --- a/mailnews/base/util/nsMsgProtocol.cpp +++ b/mailnews/base/util/nsMsgProtocol.cpp @@ -109,7 +109,7 @@ nsMsgProtocol::OpenNetworkSocketWithInfo(const char * aHostName, m_startPosition = 0; rv = socketService->CreateTransportOfType(connectionType, aHostName, - aGetPort, nsnull, -1, 0, 0, + aGetPort, nsnull, 0, 0, getter_AddRefs(m_transport)); if (NS_FAILED(rv)) return rv; diff --git a/mailnews/compose/src/nsSmtpService.cpp b/mailnews/compose/src/nsSmtpService.cpp index 1bde55a5e5d7..3822dbf0e2a1 100644 --- a/mailnews/compose/src/nsSmtpService.cpp +++ b/mailnews/compose/src/nsSmtpService.cpp @@ -279,7 +279,7 @@ nsSmtpService::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) return NS_OK; } -NS_IMETHODIMP nsSmtpService::GetURIType(PRInt16 *result) +NS_IMETHODIMP nsSmtpService::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE; return NS_OK; diff --git a/mailnews/imap/src/nsImapProtocol.cpp b/mailnews/imap/src/nsImapProtocol.cpp index 8a27fe084770..633d1737704b 100644 --- a/mailnews/imap/src/nsImapProtocol.cpp +++ b/mailnews/imap/src/nsImapProtocol.cpp @@ -614,9 +614,9 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer) connectionType = "ssl-forcehandshake"; if (m_overRideUrlConnectionInfo) - rv = socketService->CreateTransportOfType(connectionType, m_logonHost.get(), m_logonPort, nsnull, -1, 0, 0, getter_AddRefs(m_channel)); + rv = socketService->CreateTransportOfType(connectionType, m_logonHost.get(), m_logonPort, nsnull, 0, 0, getter_AddRefs(m_channel)); else - rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, -1, 0, 0, getter_AddRefs(m_channel)); + rv = socketService->CreateTransportOfType(connectionType, hostName, port, nsnull, 0, 0, getter_AddRefs(m_channel)); // Ensure that the socket can get the notification callbacks nsCOMPtr callbacks; diff --git a/mailnews/imap/src/nsImapService.cpp b/mailnews/imap/src/nsImapService.cpp index 020e2c214277..c8289019691b 100644 --- a/mailnews/imap/src/nsImapService.cpp +++ b/mailnews/imap/src/nsImapService.cpp @@ -3165,7 +3165,7 @@ NS_IMETHODIMP nsImapService::GetDefaultPort(PRInt32 *aDefaultPort) return NS_OK; } -NS_IMETHODIMP nsImapService::GetURIType(PRInt16 *result) +NS_IMETHODIMP nsImapService::GetProtocolFlags(PRUint32 *result) { *result = URI_STD; return NS_OK; diff --git a/mailnews/local/src/nsMailboxService.cpp b/mailnews/local/src/nsMailboxService.cpp index 2456610920a0..a76b6f2a3ac4 100644 --- a/mailnews/local/src/nsMailboxService.cpp +++ b/mailnews/local/src/nsMailboxService.cpp @@ -466,7 +466,7 @@ NS_IMETHODIMP nsMailboxService::AllowPort(PRInt32 port, const char *scheme, PRBo return NS_OK; } -NS_IMETHODIMP nsMailboxService::GetURIType(PRInt16 *result) +NS_IMETHODIMP nsMailboxService::GetProtocolFlags(PRUint32 *result) { *result = URI_STD; return NS_OK; diff --git a/mailnews/local/src/nsPop3Service.cpp b/mailnews/local/src/nsPop3Service.cpp index 8e730a398c05..f42b01fc732b 100644 --- a/mailnews/local/src/nsPop3Service.cpp +++ b/mailnews/local/src/nsPop3Service.cpp @@ -326,7 +326,7 @@ NS_IMETHODIMP nsPop3Service::GetDefaultDoBiff(PRBool *aDoBiff) return NS_OK; } -NS_IMETHODIMP nsPop3Service::GetURIType(PRInt16 *result) +NS_IMETHODIMP nsPop3Service::GetProtocolFlags(PRUint32 *result) { NS_ENSURE_ARG_POINTER(result); *result = URI_NORELATIVE; diff --git a/mailnews/news/src/nsNntpService.cpp b/mailnews/news/src/nsNntpService.cpp index 85e50f490a4f..3d6c5fad39d1 100644 --- a/mailnews/news/src/nsNntpService.cpp +++ b/mailnews/news/src/nsNntpService.cpp @@ -1245,7 +1245,7 @@ nsNntpService::GetDefaultServerPort(PRBool isSecure, PRInt32 *aDefaultPort) return rv; } -NS_IMETHODIMP nsNntpService::GetURIType(PRInt16 *aUritype) +NS_IMETHODIMP nsNntpService::GetProtocolFlags(PRUint32 *aUritype) { NS_ENSURE_ARG_POINTER(aUritype); *aUritype = URI_NORELATIVE; diff --git a/modules/libjar/nsJARProtocolHandler.cpp b/modules/libjar/nsJARProtocolHandler.cpp index e701d7790f63..c7be2c81e561 100644 --- a/modules/libjar/nsJARProtocolHandler.cpp +++ b/modules/libjar/nsJARProtocolHandler.cpp @@ -112,7 +112,7 @@ nsJARProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsJARProtocolHandler::GetURIType(PRInt16 *result) +nsJARProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; /* Although jar uris have their own concept of relative urls diff --git a/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp b/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp index 3fe684409525..cf0298a692cc 100644 --- a/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp +++ b/modules/libpr0n/decoders/icon/nsIconProtocolHandler.cpp @@ -66,7 +66,7 @@ NS_IMETHODIMP nsIconProtocolHandler::AllowPort(PRInt32 port, const char *scheme, return NS_OK; } -NS_IMETHODIMP nsIconProtocolHandler::GetURIType(PRInt16 *result) +NS_IMETHODIMP nsIconProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index 1148e04256ae..3ca01836a00d 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -62,6 +62,8 @@ #include "nsIScriptablePlugin.h" #include "nsICachingChannel.h" #include "nsHashtable.h" +#include "nsIProxyInfo.h" + #include "nsPluginLogging.h" #include "nsAppDirectoryServiceDefs.h" @@ -1577,6 +1579,7 @@ NS_IMPL_ISUPPORTS3(nsPluginStreamListenerPeer, nsIHttpHeaderVisitor) //////////////////////////////////////////////////////////////////////// + /* Called as a result of GetURL and PostURL */ //////////////////////////////////////////////////////////////////////// nsresult nsPluginStreamListenerPeer::Initialize(nsIURI *aURL, @@ -2876,8 +2879,6 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result) nsCOMPtr proxyService; nsCOMPtr ioService; PRBool isProxyEnabled; - nsXPIDLCString proxyHost, proxyType; - PRInt32 proxyPort; proxyService = do_GetService(kProtocolProxyServiceCID, &res); if (NS_FAILED(res) || !proxyService) { @@ -2907,19 +2908,30 @@ NS_IMETHODIMP nsPluginHostImpl::FindProxyForURL(const char* url, char* *result) return res; } + nsCOMPtr pi; + res = proxyService->ExamineForProxy(uriIn, - getter_Copies(proxyHost), - &proxyPort, - getter_Copies(proxyType)); + getter_AddRefs(pi)); if (NS_FAILED(res)) { return res; } - if (!isProxyEnabled || !proxyHost.get() || proxyPort <= 0) { + if (!pi || !pi->Host() || pi->Port() <= 0) { + *result = PL_strdup("DIRECT"); + } else if (!nsCRT::strcasecmp(pi->Type(), "http")) { + *result = PR_smprintf("PROXY %s:%d", pi->Host(), pi->Port()); + } else if (!nsCRT::strcasecmp(pi->Type(), "socks4")) { + *result = PR_smprintf("SOCKS %s:%d", pi->Host(), pi->Port()); + } else if (!nsCRT::strcasecmp(pi->Type(), "socks")) { + // XXX - this is socks5, but there is no API for us to tell the + // plugin that fact. SOCKS for now, in case the proxy server + // speaks SOCKS4 as well. See bug 78176 + // For a long time this was returning an http proxy type, so + // very little is probably broken by this + *result = PR_smprintf("SOCKS %s:%d", pi->Host(), pi->Port()); + } else { + NS_ASSERTION(PR_FALSE, "Unknown proxy type!"); *result = PL_strdup("DIRECT"); - } - else { - *result = PR_smprintf("PROXY %s:%d", (const char *) proxyHost, proxyPort); } if (nsnull == *result) { diff --git a/netwerk/base/public/MANIFEST_IDL b/netwerk/base/public/MANIFEST_IDL index cd3fd331ca48..ef047ba694c2 100644 --- a/netwerk/base/public/MANIFEST_IDL +++ b/netwerk/base/public/MANIFEST_IDL @@ -11,8 +11,10 @@ nsIFileTransportService.idl nsIPasswordManager.idl nsIPrompt.idl nsIProtocolProxyService.idl +nsIProxiedProtocolHandler.idl nsIProxyAutoConfig.idl nsIProxyAutoConfigUtils.idl +nsIProxyInfo.idl nsIProxy.idl nsIRequest.idl nsISocketTransportService.idl diff --git a/netwerk/base/public/Makefile.in b/netwerk/base/public/Makefile.in index 60ff4872c5aa..56b51d49a9cc 100644 --- a/netwerk/base/public/Makefile.in +++ b/netwerk/base/public/Makefile.in @@ -46,9 +46,11 @@ XPIDLSRCS = \ nsIPrompt.idl \ nsIProtocolHandler.idl \ nsIProtocolProxyService.idl \ + nsIProxiedProtocolHandler.idl \ nsIProxy.idl \ nsIProxyAutoConfig.idl \ nsIProxyAutoConfigUtils.idl \ + nsIProxyInfo.idl \ nsIRequest.idl \ nsITransport.idl \ nsISocketTransport.idl \ diff --git a/netwerk/base/public/makefile.win b/netwerk/base/public/makefile.win index c0b4215ca759..25a72f92ee85 100644 --- a/netwerk/base/public/makefile.win +++ b/netwerk/base/public/makefile.win @@ -48,8 +48,10 @@ XPIDLSRCS = \ .\nsIPrompt.idl \ .\nsIProtocolHandler.idl \ .\nsIProtocolProxyService.idl \ + .\nsIProxiedProtocolHandler.idl \ .\nsIProxyAutoConfig.idl \ .\nsIProxyAutoConfigUtils.idl \ + .\nsIProxyInfo.idl \ .\nsIProxy.idl \ .\nsIRequest.idl \ .\nsITransport.idl \ diff --git a/netwerk/base/public/nsIIOService.idl b/netwerk/base/public/nsIIOService.idl index 3bf692345a02..ea4e9e8464a0 100644 --- a/netwerk/base/public/nsIIOService.idl +++ b/netwerk/base/public/nsIIOService.idl @@ -40,12 +40,12 @@ interface nsIIOService : nsISupports nsIProtocolHandler getProtocolHandler(in string scheme); /** - * Returns a uritype for a given scheme. + * Returns the protocol flags for a given scheme. * * @param scheme URI scheme - * @return returns short for uritype definition + * @return returns unsigned long for protocol flags */ - short getURIType(in string scheme); + unsigned long getProtocolFlags(in string scheme); /** * This method constructs a new URI by first determining the scheme diff --git a/netwerk/base/public/nsIProtocolHandler.idl b/netwerk/base/public/nsIProtocolHandler.idl index c156bd3f76be..e805c3d6784b 100644 --- a/netwerk/base/public/nsIProtocolHandler.idl +++ b/netwerk/base/public/nsIProtocolHandler.idl @@ -46,17 +46,32 @@ interface nsIProtocolHandler : nsISupports /* standard full uri, has authority component and has concept of relative uris (http, ftp, ...) */ - const short URI_STD = 0; + const unsigned long URI_STD = 0; /* no concept of relative uris, (about, rdf, javascript, finger, ...) */ - const short URI_NORELATIVE = (1<<0); + const unsigned long URI_NORELATIVE = (1<<0); /* no authority component (file, ...) */ - const short URI_NOAUTH = (1<<1); + const unsigned long URI_NOAUTH = (1<<1); + + /* This uri can be proxied via a proxy (socks or http) + * (ie irc, smtp, http, etc). If the protocol supports transparent + * proxying, the handler should implement nsIProxiedProtocolHandler + * If it supports http proxying, then it should also set the flag + * ALLOWS_PROXY_HTTP (see below) + * + * @see nsIProxiedProtocolHandler + */ + const unsigned long ALLOWS_PROXY = (1<<2); + + /* This uri can be proxied using an http proxy (ie http, ftp, etc). + * You need to have ALLOWS_PROXY set as well, if you want this to do anything + */ + const unsigned long ALLOWS_PROXY_HTTP = (1<<3); /* more to come as needed */ - readonly attribute short URIType; + readonly attribute unsigned long protocolFlags; /** * Makes a URI object that is suitable for loading by this protocol. diff --git a/netwerk/base/public/nsIProtocolProxyService.idl b/netwerk/base/public/nsIProtocolProxyService.idl index 34f350770ce7..5a3d0f584de9 100644 --- a/netwerk/base/public/nsIProtocolProxyService.idl +++ b/netwerk/base/public/nsIProtocolProxyService.idl @@ -23,6 +23,8 @@ #include "nsISupports.idl" #include "nsIURI.idl" +interface nsIProxyInfo; + %{C++ #define NS_PROTOCOLPROXYSERVICE_CID \ { /* E9B301C0-E0E4-11d3-A1A8-0050041CAF44 */ \ @@ -34,7 +36,11 @@ interface nsIProtocolProxyService : nsISupports { readonly attribute PRBool proxyEnabled; - void examineForProxy(in nsIURI aURI, out string host, out long port, out string type); + /** Given a uri, return a proxyInfo */ + nsIProxyInfo examineForProxy(in nsIURI aURI); + + /** Return a proxyInfo with the given data */ + nsIProxyInfo newProxyInfo(in string type, in string host, in long port); /** * Add additional items in the "No proxy for" list. This is above diff --git a/netwerk/base/public/nsIProxiedProtocolHandler.idl b/netwerk/base/public/nsIProxiedProtocolHandler.idl new file mode 100644 index 000000000000..6c9b93f79e1d --- /dev/null +++ b/netwerk/base/public/nsIProxiedProtocolHandler.idl @@ -0,0 +1,38 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla. + * + * The Initial Developer of the Original Code is Netscape + * Communications. Portions created by Netscape Communications are + * Copyright (C) 2001 by Netscape Communications. All + * Rights Reserved. + * + * Contributor(s): Bradley Baetz (original author) + * + */ + +#include "nsIProtocolHandler.idl" + +interface nsIChannel; +interface nsIURI; +interface nsIProxyInfo; + +[scriptable, uuid(0a24fed4-1dd2-11b2-a75c-9f8b9a8f9ba7)] +interface nsIProxiedProtocolHandler : nsIProtocolHandler +{ + /** Create a new channel with the given proxyInfo + * + */ + nsIChannel newProxiedChannel(in nsIURI uri, in nsIProxyInfo proxyInfo); +}; + diff --git a/netwerk/base/public/nsIProxyInfo.idl b/netwerk/base/public/nsIProxyInfo.idl new file mode 100644 index 000000000000..6e38100ccdc1 --- /dev/null +++ b/netwerk/base/public/nsIProxyInfo.idl @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Bradley Baetz (Original Developer) + */ + +#include "nsISupports.idl" + +/* This interface is PRIVATE. + * It is used as an opaque cookie, and this class may change at + * any time without notice. + * + * @see nsIProtocolProxyService::GetProxyInfo + */ + +native constCharPtr(const char*); + +[scriptable, uuid(b65d22b0-1dd1-11b2-8f95-920e5b7b56f0)] +interface nsIProxyInfo : nsISupports +{ + [noscript, notxpcom] constCharPtr Host(); + [noscript, notxpcom] PRInt32 Port(); + [noscript, notxpcom] constCharPtr Type(); +}; + diff --git a/netwerk/base/public/nsISocketTransportService.idl b/netwerk/base/public/nsISocketTransportService.idl index 012810223a33..5b2bfb6d4f50 100644 --- a/netwerk/base/public/nsISocketTransportService.idl +++ b/netwerk/base/public/nsISocketTransportService.idl @@ -25,30 +25,33 @@ interface nsITransport; interface nsIEventSinkGetter; interface nsIChannel; +interface nsIProxyInfo; [scriptable, uuid(05331390-6884-11d3-9382-00104ba0fd40)] interface nsISocketTransportService : nsISupports { /** - * Creates a transport for a specified host and port. - * The eventSinkGetter is used to get the appropriate callbacks - * for the socket activity from the application. These include - * the progress and the status messages like "Contacting host.." - * etc. The printHost contains the actual hostname (and not the - * proxy) for displaying in status messages. + * Creates a transport for a specified host and port. + * + * @param proxyInfo Information about any transport-layer proxying. Used + * for communicating information about proxies like socks. + * This can either be the proxyInfo attribute on an + * nsISupportsTransparentProxy (or from the protocolProxyService), + * or null for no proxying. + * + * @see nsISupportsTransparentProxy + * @see nsIProtocolProxyService::GetProxyInfo */ nsITransport createTransport(in string host, in long port, - in string proxyHost, - in long proxyPort, + in nsIProxyInfo proxyInfo, in unsigned long bufferSegmentSize, in unsigned long bufferMaxSize); nsITransport createTransportOfType(in string socketType, in string host, in long port, - in string proxyHost, - in long proxyPort, + in nsIProxyInfo proxyInfo, in unsigned long bufferSegmentSize, in unsigned long bufferMaxSize); @@ -56,8 +59,7 @@ interface nsISocketTransportService : nsISupports [array, size_is(typeCount)] in string socketTypes, in string host, in long port, - in string proxyHost, - in long proxyPort, + in nsIProxyInfo proxyInfo, in unsigned long bufferSegmentSize, in unsigned long bufferMaxSize); diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index 7bf806f39650..df0f160ac7da 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -51,6 +51,7 @@ #include "nsILocalFile.h" #include "nsIFileStreams.h" #include "nsXPIDLString.h" +#include "nsIProtocolProxyService.h" #include "prio.h" // for read/write flags, permissions, etc. #include "nsNetCID.h" @@ -675,4 +676,17 @@ NS_CheckPortSafety(PRInt32 port, const char* scheme, nsIIOService* ioService = n return NS_OK; } +inline nsresult +NS_NewProxyInfo(const char* type, const char* host, PRInt32 port, nsIProxyInfo* *result) +{ + nsresult rv; + + static NS_DEFINE_CID(kPPSServiceCID, NS_PROTOCOLPROXYSERVICE_CID); + nsCOMPtr pps = do_GetService(kPPSServiceCID,&rv); + + if (NS_FAILED(rv)) return rv; + + return pps->NewProxyInfo(type, host, port, result); +} + #endif // nsNetUtil_h__ diff --git a/netwerk/base/src/nsIOService.cpp b/netwerk/base/src/nsIOService.cpp index 48e03bad4708..7094cd30ea52 100644 --- a/netwerk/base/src/nsIOService.cpp +++ b/netwerk/base/src/nsIOService.cpp @@ -40,6 +40,8 @@ #include "nsICategoryManager.h" #include "nsIURLParser.h" #include "nsISupportsPrimitives.h" +#include "nsIProxiedProtocolHandler.h" +#include "nsIProxyInfo.h" #include "nsITimelineService.h" #include "nsEscape.h" @@ -636,14 +638,14 @@ nsIOService::ExtractUrlPart(const char *urlString, PRInt16 flag, PRUint32 *start } NS_IMETHODIMP -nsIOService::GetURIType(const char* scheme, PRInt16 *uritype) +nsIOService::GetProtocolFlags(const char* scheme, PRUint32 *flags) { nsCOMPtr handler; nsresult rv = GetProtocolHandler(scheme, getter_AddRefs(handler)); if (NS_FAILED(rv)) { return rv; } - rv = handler->GetURIType(uritype); + rv = handler->GetProtocolFlags(flags); return rv; } @@ -708,7 +710,6 @@ nsIOService::NewFileURI(nsIFile *aSpec, nsIURI **_retval) return NewURI(urlString, nsnull, _retval); } - NS_IMETHODIMP nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result) { @@ -720,36 +721,28 @@ nsIOService::NewChannelFromURI(nsIURI *aURI, nsIChannel **result) rv = aURI->GetScheme(getter_Copies(scheme)); if (NS_FAILED(rv)) return rv; - nsCOMPtr handler; - rv = GetProtocolHandler((const char*)scheme, getter_AddRefs(handler)); + nsCOMPtr pi; + rv = mProxyService->ExamineForProxy(aURI, getter_AddRefs(pi)); if (NS_FAILED(rv)) return rv; - PRBool useProxy = PR_FALSE; - if (mProxyService) { - mProxyService->GetProxyEnabled(&useProxy); - if (useProxy) { - nsXPIDLCString host, type; - PRInt32 port; - rv = mProxyService->ExamineForProxy(aURI, getter_Copies(host), &port, getter_Copies(type)); - if (NS_SUCCEEDED(rv) && type.get()) - { - // we are going to proxy this channel and the only protocol that can do proxying is http - rv = GetProtocolHandler("http", getter_AddRefs(handler)); - if (NS_FAILED(rv)) return rv; - - nsCOMPtr httpHandler = do_QueryInterface(handler, &rv); - if (NS_FAILED(rv)) - return rv; + nsCOMPtr handler; - if (!httpHandler) - return NS_ERROR_NULL_POINTER; - - return httpHandler->NewProxyChannel(aURI, host, port, type, result); - } - } + if (pi && !nsCRT::strcmp(pi->Type(),"http")) { + // we are going to proxy this channel using an http proxy + rv = GetProtocolHandler("http", getter_AddRefs(handler)); + if (NS_FAILED(rv)) return rv; + } else { + rv = GetProtocolHandler(scheme.get(), getter_AddRefs(handler)); + if (NS_FAILED(rv)) return rv; } - rv = handler->NewChannel(aURI, result); + nsCOMPtr pph = do_QueryInterface(handler); + + if (pph) + rv = pph->NewProxiedChannel(aURI, pi, result); + else + rv = handler->NewChannel(aURI, result); + return rv; } diff --git a/netwerk/base/src/nsProtocolProxyService.cpp b/netwerk/base/src/nsProtocolProxyService.cpp index 2a2d89464e05..c33e1745e5d2 100644 --- a/netwerk/base/src/nsProtocolProxyService.cpp +++ b/netwerk/base/src/nsProtocolProxyService.cpp @@ -28,6 +28,7 @@ #include "nsNetCID.h" #include "nsIIOService.h" #include "nsIEventQueueService.h" +#include "nsIProtocolHandler.h" static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -43,6 +44,7 @@ static PRInt32 PR_CALLBACK ProxyPrefsCallback(const char* pref, void* instance) NS_IMPL_THREADSAFE_ISUPPORTS1(nsProtocolProxyService, nsIProtocolProxyService); +NS_IMPL_THREADSAFE_ISUPPORTS1(nsProtocolProxyService::nsProxyInfo, nsIProxyInfo); nsProtocolProxyService::nsProtocolProxyService(): @@ -324,26 +326,30 @@ nsProtocolProxyService::CanUseProxy(nsIURI* aURI) // nsIProtocolProxyService NS_IMETHODIMP -nsProtocolProxyService::ExamineForProxy(nsIURI *aURI, char * *aProxyHost, PRInt32 *aProxyPort, char * *aProxyType) { +nsProtocolProxyService::ExamineForProxy(nsIURI *aURI, nsIProxyInfo* *aResult) { nsresult rv = NS_OK; NS_ASSERTION(aURI, "need a uri folks."); - - NS_ENSURE_ARG_POINTER(aProxyHost); - NS_ENSURE_ARG_POINTER(aProxyType); - *aProxyHost = nsnull; - *aProxyType = nsnull; - *aProxyPort = -1; - - // we only know about http, https, ftp and gopher as yet... - // return nothing for others. See what happens otherwise in bug 81214 - PRBool validScheme = PR_FALSE; - if ((NS_FAILED(aURI->SchemeIs("http", &validScheme)) || !validScheme) && - (NS_FAILED(aURI->SchemeIs("https", &validScheme)) || !validScheme) && - (NS_FAILED(aURI->SchemeIs("ftp", &validScheme)) || !validScheme ) && - (NS_FAILED(aURI->SchemeIs("gopher", &validScheme)) || !validScheme)) - return NS_OK; + *aResult = nsnull; + + nsCOMPtr ios = do_GetService(kIOServiceCID, &rv); + if (NS_FAILED(rv)) return rv; + + nsXPIDLCString scheme; + rv = aURI->GetScheme(getter_Copies(scheme)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr handler; + rv = ios->GetProtocolHandler(scheme.get(), getter_AddRefs(handler)); + if (NS_FAILED(rv)) return rv; + + PRUint32 flags; + rv = handler->GetProtocolFlags(&flags); + if (NS_FAILED(rv)) return rv; + + if (!(flags & nsIProtocolHandler::ALLOWS_PROXY)) + return NS_OK; // Can't proxy this // if proxies are enabled and this host:port combo is // supposed to use a proxy, check for a proxy. @@ -351,93 +357,118 @@ nsProtocolProxyService::ExamineForProxy(nsIURI *aURI, char * *aProxyHost, PRInt3 ((1 == mUseProxy) && !CanUseProxy(aURI))) { return NS_OK; } + + nsProxyInfo* proxyInfo = nsnull; + NS_NEWXPCOM(proxyInfo, nsProxyInfo); + if (!proxyInfo) + return NS_ERROR_OUT_OF_MEMORY; // Proxy auto config magic... if (2 == mUseProxy) { if (!mPAC) { NS_ERROR("ERROR: PAC js component is null"); + delete proxyInfo; return NS_ERROR_NULL_POINTER; } rv = mPAC->ProxyForURL(aURI, - aProxyHost, - aProxyPort, - aProxyType); - if (NS_SUCCEEDED(rv)) { - if (*aProxyType == nsnull || !PL_strcasecmp("direct", *aProxyType)) { - if (*aProxyHost) { - nsMemory::Free(*aProxyHost); - *aProxyHost = nsnull; - } - if (*aProxyType) { - nsMemory::Free(*aProxyType); - *aProxyType = nsnull; - } - *aProxyPort = -1; - } else if (*aProxyPort <= 0) { - *aProxyPort = -1; - } - } - return rv; + &proxyInfo->mHost, + &proxyInfo->mPort, + &proxyInfo->mType); + if (NS_FAILED(rv) || !proxyInfo->Type() || // If: it didn't work + !PL_strcasecmp("direct", proxyInfo->Type()) || // OR we're meant to go direct + (PL_strcasecmp("http", proxyInfo->Type()) != 0 && // OR we're an http proxy... + !(flags & nsIProtocolHandler::ALLOWS_PROXY_HTTP))) { // ... but we can't proxy with http + delete proxyInfo; // don't proxy this + } else { + if (proxyInfo->Port() <= 0) + proxyInfo->mPort = -1; + NS_ADDREF(*aResult = proxyInfo); + } + return rv; } - nsXPIDLCString scheme; - rv = aURI->GetScheme(getter_Copies(scheme)); - if (NS_FAILED(rv)) return rv; + // Nothing below here returns failure + NS_ADDREF(*aResult = proxyInfo); + + PRBool isScheme = PR_FALSE; if (mHTTPProxyHost.get()[0] && mHTTPProxyPort > 0 && - !PL_strcasecmp(scheme, "http")) { - *aProxyHost = PL_strdup(mHTTPProxyHost); - *aProxyType = PL_strdup("http"); - *aProxyPort = mHTTPProxyPort; + NS_SUCCEEDED(aURI->SchemeIs("http", &isScheme)) && isScheme) { + proxyInfo->mHost = PL_strdup(mHTTPProxyHost); + proxyInfo->mType = PL_strdup("http"); + proxyInfo->mPort = mHTTPProxyPort; return NS_OK; } if (mHTTPSProxyHost.get()[0] && mHTTPSProxyPort > 0 && - !PL_strcasecmp(scheme, "https")) { - *aProxyHost = PL_strdup(mHTTPSProxyHost); - *aProxyType = PL_strdup("http"); - *aProxyPort = mHTTPSProxyPort; + NS_SUCCEEDED(aURI->SchemeIs("https", &isScheme)) && isScheme) { + proxyInfo->mHost = PL_strdup(mHTTPSProxyHost); + proxyInfo->mType = PL_strdup("http"); + proxyInfo->mPort = mHTTPSProxyPort; return NS_OK; } if (mFTPProxyHost.get()[0] && mFTPProxyPort > 0 && - !PL_strcasecmp(scheme, "ftp")) { - *aProxyHost = PL_strdup(mFTPProxyHost); - *aProxyType = PL_strdup("http"); - *aProxyPort = mFTPProxyPort; + NS_SUCCEEDED(aURI->SchemeIs("ftp", &isScheme)) && isScheme) { + proxyInfo->mHost = PL_strdup(mFTPProxyHost); + proxyInfo->mType = PL_strdup("http"); + proxyInfo->mPort = mFTPProxyPort; return NS_OK; } if (mGopherProxyHost.get()[0] && mGopherProxyPort > 0 && - !PL_strcasecmp(scheme, "gopher")) { - *aProxyHost = PL_strdup(mGopherProxyHost); - *aProxyType = PL_strdup("http"); - *aProxyPort = mGopherProxyPort; + NS_SUCCEEDED(aURI->SchemeIs("gopher", &isScheme)) && isScheme) { + proxyInfo->mHost = PL_strdup(mGopherProxyHost); + proxyInfo->mType = PL_strdup("http"); + proxyInfo->mPort = mGopherProxyPort; return NS_OK; } if (mSOCKSProxyHost.get()[0] && mSOCKSProxyPort > 0 && mSOCKSProxyVersion == 4) { - *aProxyHost = PL_strdup(mSOCKSProxyHost); - *aProxyPort = mSOCKSProxyPort; - *aProxyType = PL_strdup("socks4"); + proxyInfo->mHost = PL_strdup(mSOCKSProxyHost); + proxyInfo->mPort = mSOCKSProxyPort; + proxyInfo->mType = PL_strdup("socks4"); return NS_OK; } if (mSOCKSProxyHost.get()[0] && mSOCKSProxyPort > 0 && mSOCKSProxyVersion == 5) { - *aProxyHost = PL_strdup(mSOCKSProxyHost); - *aProxyPort = mSOCKSProxyPort; - *aProxyType = PL_strdup("socks"); + proxyInfo->mHost = PL_strdup(mSOCKSProxyHost); + proxyInfo->mPort = mSOCKSProxyPort; + proxyInfo->mType = PL_strdup("socks"); return NS_OK; } + NS_RELEASE(*aResult); // Will call destructor return NS_OK; } +NS_IMETHODIMP +nsProtocolProxyService::NewProxyInfo(const char* type, const char* host, + PRInt32 port, nsIProxyInfo* *result) +{ + nsProxyInfo* proxyInfo = nsnull; + NS_NEWXPCOM(proxyInfo, nsProxyInfo); + if (!proxyInfo) + return NS_ERROR_OUT_OF_MEMORY; + + if (type) + proxyInfo->mType = nsCRT::strdup(type); + + if (host) + proxyInfo->mHost = nsCRT::strdup(host); + + proxyInfo->mPort = port; + + *result = proxyInfo; + NS_ADDREF(*result); + return NS_OK; +} + NS_IMETHODIMP nsProtocolProxyService::ConfigureFromPAC(const char *url) { @@ -612,4 +643,3 @@ nsProtocolProxyService::LoadFilters(const char* filters) np = endproxy; } } - diff --git a/netwerk/base/src/nsProtocolProxyService.h b/netwerk/base/src/nsProtocolProxyService.h index ef271c70aba3..128f1b1309eb 100644 --- a/netwerk/base/src/nsProtocolProxyService.h +++ b/netwerk/base/src/nsProtocolProxyService.h @@ -31,6 +31,8 @@ #include "nsXPIDLString.h" #include "nsIProtocolProxyService.h" #include "nsIProxyAutoConfig.h" +#include "nsIProxyInfo.h" +#include "prmem.h" class nsProtocolProxyService : public nsIProtocolProxyService { public: @@ -47,6 +49,35 @@ public: void PrefsChanged(const char* pref); + class nsProxyInfo : public nsIProxyInfo { + NS_DECL_ISUPPORTS + + NS_IMETHOD_(const char*) Host() { + return mHost; + } + + NS_IMETHOD_(PRInt32) Port() { + return mPort; + } + + NS_IMETHOD_(const char*) Type() { + return mType; + } + + virtual ~nsProxyInfo() { + PR_FREEIF(mHost); + PR_FREEIF(mType); + } + + nsProxyInfo() : mType(nsnull), mHost(nsnull), mPort(-1) { + NS_INIT_REFCNT(); + } + + char* mType; + char* mHost; + PRInt32 mPort; + }; + protected: void LoadFilters(const char* filters); diff --git a/netwerk/base/src/nsProxyAutoConfig.js b/netwerk/base/src/nsProxyAutoConfig.js index d3bad70354ef..2b5ddc950764 100644 --- a/netwerk/base/src/nsProxyAutoConfig.js +++ b/netwerk/base/src/nsProxyAutoConfig.js @@ -103,7 +103,6 @@ nsProxyAutoConfig.prototype = { }, onStopRequest: function(request, ctxt, status, errorMsg) { - this.done = true; if(!ProxySandBox) { ProxySandBox = new Sandbox(); } @@ -120,6 +119,7 @@ nsProxyAutoConfig.prototype = { } ProxySandBox.dnsResolve = dnsResolve; LocalFindProxyForURL=ProxySandBox.FindProxyForURL; + this.done = true; }, onDataAvailable: function(request, ctxt, inStream, sourceOffset, count) { diff --git a/netwerk/base/src/nsSocketTransport.cpp b/netwerk/base/src/nsSocketTransport.cpp index 190a1e386ef1..5361cf5596ec 100644 --- a/netwerk/base/src/nsSocketTransport.cpp +++ b/netwerk/base/src/nsSocketTransport.cpp @@ -44,6 +44,7 @@ #include "nsISSLSocketControl.h" #include "nsITransportSecurityInfo.h" #include "nsMemory.h" +#include "nsIProxyInfo.h" #if defined(PR_LOGGING) static PRLogModuleInfo *gSocketTransportLog = nsnull; @@ -127,13 +128,12 @@ nsSocketTransport::nsSocketTransport(): mSocketConnectTimeout(PR_MillisecondsToInterval(DEFAULT_SOCKET_CONNECT_TIMEOUT_IN_MS)), mCurrentState(eSocketState_Created), mHostName(nsnull), - mPort(0), + mPort(-1), mMonitor(nsnull), mOperation(eSocketOperation_None), - mProxyPort(0), + mProxyPort(-1), mProxyHost(nsnull), mProxyTransparent(PR_FALSE), - mSSLProxy(PR_FALSE), mClosePending(PR_FALSE), mWasConnected(PR_FALSE), mService(nsnull), @@ -229,8 +229,7 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, PRInt32 aPort, PRUint32 aSocketTypeCount, const char* *aSocketTypes, - const char* aProxyHost, - PRInt32 aProxyPort, + nsIProxyInfo* aProxyInfo, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize) { @@ -245,7 +244,8 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, NS_ADDREF(mService); mPort = aPort; - mProxyPort = aProxyPort; + if (aProxyInfo) + mProxyPort = aProxyInfo->Port(); if (aHost && *aHost) { mHostName = nsCRT::strdup(aHost); @@ -255,13 +255,20 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, else // hostname was nsnull or empty... rv = NS_ERROR_FAILURE; - if (aProxyHost && *aProxyHost) { - mProxyHost = nsCRT::strdup(aProxyHost); + if (aProxyInfo && aProxyInfo->Host()) { + mProxyHost = nsCRT::strdup(aProxyInfo->Host()); if (!mProxyHost) rv = NS_ERROR_OUT_OF_MEMORY; } - if (NS_SUCCEEDED(rv) && aSocketTypeCount) { + if (NS_SUCCEEDED(rv) && (aSocketTypeCount || aProxyInfo)) { + const char* proxyType = nsnull; + + if (aProxyInfo && nsCRT::strcmp(aProxyInfo->Type(), "http") != 0) { + proxyType = aProxyInfo->Type(); + ++aSocketTypeCount; + } + mSocketTypes = (char**) nsMemory::Alloc(aSocketTypeCount * sizeof(char*)); if (!mSocketTypes) rv = NS_ERROR_OUT_OF_MEMORY; @@ -272,8 +279,17 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, return rv; nsCOMPtr provider; - for (PRUint32 type = 0; type < aSocketTypeCount; type++) { - const char * socketType = aSocketTypes[type]; + for (PRUint32 type = 0, pos = 0; pos < aSocketTypeCount; ++type, ++pos) { + + const char * socketType = nsnull; + + // Push a transport layer proxy if we have one + if (proxyType) { + socketType = proxyType; + } else { + socketType = aSocketTypes[type]; + } + if (socketType == nsnull) continue; #ifdef DEBUG @@ -304,8 +320,12 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService, // the default proxy behavior mProxyTransparent = PR_TRUE; } - if (mProxyHost && (nsCRT::strcmp(socketType, "ssl") == 0)) - mSSLProxy = PR_TRUE; + + // then go back to normal + if (proxyType) { + --type; + proxyType = nsnull; + } } } } @@ -858,7 +878,7 @@ nsresult nsSocketTransport::doConnection(PRInt16 aSelectFlags) "rv = %x.\n\n", mHostName, mPort, this, rv)); - if (rv == NS_OK && mSecurityInfo && mProxyHost && mProxyHost && proxyTransparent) { + if (rv == NS_OK && mSecurityInfo && mProxyHost && proxyTransparent) { // if the connection phase is finished, and the ssl layer // has been pushed, and we were proxying (transparently; ie. nothing // has to happen in the protocol layer above us), it's time diff --git a/netwerk/base/src/nsSocketTransport.h b/netwerk/base/src/nsSocketTransport.h index 53d0a85199f3..7ef429b886d7 100644 --- a/netwerk/base/src/nsSocketTransport.h +++ b/netwerk/base/src/nsSocketTransport.h @@ -124,7 +124,7 @@ class nsSocketOS; // output stream class nsSocketRequest; class nsSocketReadRequest; class nsSocketWriteRequest; - +class nsIProxyInfo; class nsSocketTransport : public nsISocketTransport, public nsIDNSListener @@ -144,8 +144,7 @@ public: PRInt32 aPort, PRUint32 aSocketTypeCount, const char* *aSocketTypes, - const char* aProxyHost, - PRInt32 aProxyPort, + nsIProxyInfo* aProxyInfo, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize); @@ -239,7 +238,6 @@ protected: PRInt32 mProxyPort; char* mProxyHost; PRPackedBool mProxyTransparent; - PRPackedBool mSSLProxy; /* put all the packed bools together so we save space */ PRPackedBool mClosePending; diff --git a/netwerk/base/src/nsSocketTransportService.cpp b/netwerk/base/src/nsSocketTransportService.cpp index 38b7b0a99362..e797bd593db0 100644 --- a/netwerk/base/src/nsSocketTransportService.cpp +++ b/netwerk/base/src/nsSocketTransportService.cpp @@ -30,6 +30,7 @@ #include "nsProxiedService.h" #include "nsString.h" #include "nsNetCID.h" +#include "nsProtocolProxyService.h" #ifdef DEBUG // in debug builds this will be valid while the socket transport service is active. @@ -541,13 +542,12 @@ nsSocketTransportService::Run(void) NS_IMETHODIMP nsSocketTransportService::CreateTransport(const char* aHost, PRInt32 aPort, - const char* proxyHost, - PRInt32 proxyPort, + nsIProxyInfo* proxyInfo, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, nsITransport** aResult) { - return CreateTransportOfTypes(0, nsnull, aHost, aPort, proxyHost, proxyPort, + return CreateTransportOfTypes(0, nsnull, aHost, aPort, proxyInfo, bufferSegmentSize, bufferMaxSize, aResult); } @@ -555,14 +555,13 @@ NS_IMETHODIMP nsSocketTransportService::CreateTransportOfType(const char* aSocketType, const char* aHost, PRInt32 aPort, - const char* proxyHost, - PRInt32 proxyPort, + nsIProxyInfo* proxyInfo, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, nsITransport** aResult) { const char * types[] = { aSocketType }; - return CreateTransportOfTypes(1, types, aHost, aPort, proxyHost, proxyPort, + return CreateTransportOfTypes(1, types, aHost, aPort, proxyInfo, bufferSegmentSize, bufferMaxSize, aResult); } @@ -571,8 +570,7 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount, const char* *aSocketTypes, const char* aHost, PRInt32 aPort, - const char* proxyHost, - PRInt32 proxyPort, + nsIProxyInfo* aProxyInfo, PRUint32 bufferSegmentSize, PRUint32 bufferMaxSize, nsITransport** aResult) @@ -597,21 +595,20 @@ nsSocketTransportService::CreateTransportOfTypes(PRUint32 socketTypeCount, // Create and initialize a new connection object... NS_NEWXPCOM(transport, nsSocketTransport); if (transport) { - rv = transport->Init(this, aHost, aPort, socketTypeCount, aSocketTypes, - proxyHost, proxyPort, bufferSegmentSize, bufferMaxSize); - if (NS_FAILED(rv)) { - delete transport; - transport = nsnull; - } - } - else { - rv = NS_ERROR_OUT_OF_MEMORY; + rv = transport->Init(this, aHost, aPort, socketTypeCount, aSocketTypes, + aProxyInfo, bufferSegmentSize, bufferMaxSize); + if (NS_FAILED(rv)) { + delete transport; + transport = nsnull; + } + } else { + rv = NS_ERROR_OUT_OF_MEMORY; } // Set the reference count to one... - if (NS_SUCCEEDED(rv)) { - NS_ADDREF(transport); - } + if (NS_SUCCEEDED(rv)) + NS_ADDREF(transport); + *aResult = transport; return rv; diff --git a/netwerk/protocol/about/src/nsAboutProtocolHandler.cpp b/netwerk/protocol/about/src/nsAboutProtocolHandler.cpp index 509c5108ef97..30cbc023a303 100644 --- a/netwerk/protocol/about/src/nsAboutProtocolHandler.cpp +++ b/netwerk/protocol/about/src/nsAboutProtocolHandler.cpp @@ -92,7 +92,7 @@ nsAboutProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsAboutProtocolHandler::GetURIType(PRInt16 *result) +nsAboutProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; diff --git a/netwerk/protocol/data/src/nsDataHandler.cpp b/netwerk/protocol/data/src/nsDataHandler.cpp index db7ba4361ee4..437e65bb9cd0 100644 --- a/netwerk/protocol/data/src/nsDataHandler.cpp +++ b/netwerk/protocol/data/src/nsDataHandler.cpp @@ -75,7 +75,7 @@ nsDataHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsDataHandler::GetURIType(PRInt16 *result) { +nsDataHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; } diff --git a/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp b/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp index c99ff7c547ee..46fb4f81f059 100644 --- a/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp +++ b/netwerk/protocol/datetime/src/nsDateTimeChannel.cpp @@ -33,8 +33,6 @@ #include "nsITransport.h" #include "nsIProgressEventSink.h" -static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); - // nsDateTimeChannel methods nsDateTimeChannel::nsDateTimeChannel() { NS_INIT_REFCNT(); @@ -52,13 +50,14 @@ NS_IMPL_ISUPPORTS4(nsDateTimeChannel, nsIRequestObserver) nsresult -nsDateTimeChannel::Init(nsIURI* uri) +nsDateTimeChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) { nsresult rv; NS_ASSERTION(uri, "no uri"); mUrl = uri; + mProxyInfo = proxyInfo; rv = mUrl->GetPort(&mPort); if (NS_FAILED(rv) || mPort < 1) @@ -163,12 +162,17 @@ nsDateTimeChannel::Open(nsIInputStream **_retval) if (NS_FAILED(rv)) return rv; - nsCOMPtr socketService = - do_GetService(kSocketTransportServiceCID, &rv); + nsCOMPtr sts = + do_GetService("@mozilla.org/network/socket-transport-service;1", &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); + rv = sts->CreateTransport(mHost, + mPort, + mProxyInfo, + 32, + 32, + getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; transport->SetNotificationCallbacks(mCallbacks, @@ -185,12 +189,17 @@ nsDateTimeChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) if (NS_FAILED(rv)) return rv; - nsCOMPtr socketService = - do_GetService(kSocketTransportServiceCID, &rv); + nsCOMPtr sts = + do_GetService("@mozilla.org/network/socket-transport-service;1", &rv); if (NS_FAILED(rv)) return rv; nsCOMPtr transport; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, 32, 32, getter_AddRefs(transport)); + rv = sts->CreateTransport(mHost, + mPort, + mProxyInfo, + 32, + 32, + getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; transport->SetNotificationCallbacks(mCallbacks, @@ -334,4 +343,3 @@ nsDateTimeChannel::OnDataAvailable(nsIRequest *request, nsISupports* aContext, mContentLength = aLength; return mListener->OnDataAvailable(this, aContext, aInputStream, aSourceOffset, aLength); } - diff --git a/netwerk/protocol/datetime/src/nsDateTimeChannel.h b/netwerk/protocol/datetime/src/nsDateTimeChannel.h index b7118239f65d..636fcf022482 100644 --- a/netwerk/protocol/datetime/src/nsDateTimeChannel.h +++ b/netwerk/protocol/datetime/src/nsDateTimeChannel.h @@ -38,7 +38,7 @@ #include "nsIURI.h" #include "nsDateTimeHandler.h" #include "nsIStreamListener.h" - +#include "nsIProxyInfo.h" class nsDateTimeChannel : public nsIChannel, @@ -59,7 +59,7 @@ public: static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); - nsresult Init(nsIURI* uri); + nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo); protected: nsCOMPtr mCallbacks; @@ -70,7 +70,8 @@ protected: nsCOMPtr mLoadGroup; nsCString mContentType; PRInt32 mContentLength; - nsCOMPtr mOwner; + nsCOMPtr mOwner; + nsCOMPtr mProxyInfo; PRInt32 mPort; nsXPIDLCString mHost; diff --git a/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp b/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp index 1a1ebf48cf09..8e774e6461d4 100644 --- a/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp +++ b/netwerk/protocol/datetime/src/nsDateTimeHandler.cpp @@ -43,7 +43,9 @@ nsDateTimeHandler::nsDateTimeHandler() { nsDateTimeHandler::~nsDateTimeHandler() { } -NS_IMPL_ISUPPORTS1(nsDateTimeHandler, nsIProtocolHandler) +NS_IMPL_ISUPPORTS2(nsDateTimeHandler, + nsIProtocolHandler, + nsIProxiedProtocolHandler) NS_METHOD nsDateTimeHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { @@ -74,8 +76,8 @@ nsDateTimeHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsDateTimeHandler::GetURIType(PRInt16 *result) { - *result = URI_NORELATIVE | URI_NOAUTH; +nsDateTimeHandler::GetProtocolFlags(PRUint32 *result) { + *result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY; return NS_OK; } @@ -104,6 +106,13 @@ nsDateTimeHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, NS_IMETHODIMP nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result) +{ + return NewProxiedChannel(url, nsnull, result); +} + +NS_IMETHODIMP +nsDateTimeHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, + nsIChannel* *result) { nsresult rv; @@ -111,7 +120,7 @@ nsDateTimeHandler::NewChannel(nsIURI* url, nsIChannel* *result) rv = nsDateTimeChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel); if (NS_FAILED(rv)) return rv; - rv = channel->Init(url); + rv = channel->Init(url, proxyInfo); if (NS_FAILED(rv)) { NS_RELEASE(channel); return rv; diff --git a/netwerk/protocol/datetime/src/nsDateTimeHandler.h b/netwerk/protocol/datetime/src/nsDateTimeHandler.h index 9737e5525f7e..7cb99d113bd7 100644 --- a/netwerk/protocol/datetime/src/nsDateTimeHandler.h +++ b/netwerk/protocol/datetime/src/nsDateTimeHandler.h @@ -26,7 +26,7 @@ #ifndef nsDateTimeHandler_h___ #define nsDateTimeHandler_h___ -#include "nsIProtocolHandler.h" +#include "nsIProxiedProtocolHandler.h" #define DATETIME_PORT 13 @@ -34,11 +34,12 @@ #define NS_DATETIMEHANDLER_CID \ { 0xaa27d2a0, 0xb71b, 0x11d3, { 0xa1, 0xa0, 0x0, 0x50, 0x4, 0x1c, 0xaf, 0x44 } } -class nsDateTimeHandler : public nsIProtocolHandler +class nsDateTimeHandler : public nsIProxiedProtocolHandler { public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER // nsDateTimeHandler methods: nsDateTimeHandler(); diff --git a/netwerk/protocol/file/src/nsFileProtocolHandler.cpp b/netwerk/protocol/file/src/nsFileProtocolHandler.cpp index 03a6018102ef..ef6d2f74a9cc 100644 --- a/netwerk/protocol/file/src/nsFileProtocolHandler.cpp +++ b/netwerk/protocol/file/src/nsFileProtocolHandler.cpp @@ -97,7 +97,7 @@ nsFileProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsFileProtocolHandler::GetURIType(PRInt16 *result) +nsFileProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NOAUTH; return NS_OK; diff --git a/netwerk/protocol/finger/src/nsFingerChannel.cpp b/netwerk/protocol/finger/src/nsFingerChannel.cpp index 7e6898a56b9d..dffeae8ed5a3 100644 --- a/netwerk/protocol/finger/src/nsFingerChannel.cpp +++ b/netwerk/protocol/finger/src/nsFingerChannel.cpp @@ -62,7 +62,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsFingerChannel, nsIRequestObserver) nsresult -nsFingerChannel::Init(nsIURI* uri) +nsFingerChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) { nsresult rv; nsXPIDLCString autoBuffer; @@ -70,6 +70,7 @@ nsFingerChannel::Init(nsIURI* uri) NS_ASSERTION(uri, "no uri"); mUrl = uri; + mProxyInfo = proxyInfo; // For security reasons, we do not allow the user to specify a // non-default port for finger: URL's. @@ -197,7 +198,7 @@ nsFingerChannel::Open(nsIInputStream **_retval) do_GetService(kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, + rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE, BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; @@ -220,7 +221,7 @@ nsFingerChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) do_GetService(kSocketTransportServiceCID, &rv); if (NS_FAILED(rv)) return rv; - rv = socketService->CreateTransport(mHost, mPort, nsnull, -1, BUFFER_SEG_SIZE, + rv = socketService->CreateTransport(mHost, mPort, mProxyInfo, BUFFER_SEG_SIZE, BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); if (NS_FAILED(rv)) return rv; diff --git a/netwerk/protocol/finger/src/nsFingerChannel.h b/netwerk/protocol/finger/src/nsFingerChannel.h index 9086ec00aa17..cd95b1033926 100644 --- a/netwerk/protocol/finger/src/nsFingerChannel.h +++ b/netwerk/protocol/finger/src/nsFingerChannel.h @@ -35,6 +35,7 @@ #include "nsFingerHandler.h" #include "nsIStreamListener.h" #include "nsITransport.h" +#include "nsIProxyInfo.h" class nsFingerChannel : public nsIChannel, @@ -55,7 +56,7 @@ public: static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); - nsresult Init(nsIURI* uri); + nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo); protected: nsCOMPtr mCallbacks; @@ -80,6 +81,7 @@ protected: nsCOMPtr mResponseContext; nsCOMPtr mTransport; nsCOMPtr mTransportRequest; + nsCOMPtr mProxyInfo; nsresult mStatus; protected: diff --git a/netwerk/protocol/finger/src/nsFingerHandler.cpp b/netwerk/protocol/finger/src/nsFingerHandler.cpp index 3a61fd1fe1ca..dd4012bfca3b 100644 --- a/netwerk/protocol/finger/src/nsFingerHandler.cpp +++ b/netwerk/protocol/finger/src/nsFingerHandler.cpp @@ -43,7 +43,9 @@ nsFingerHandler::nsFingerHandler() { nsFingerHandler::~nsFingerHandler() { } -NS_IMPL_ISUPPORTS1(nsFingerHandler, nsIProtocolHandler) +NS_IMPL_ISUPPORTS2(nsFingerHandler, + nsIProtocolHandler, + nsIProxiedProtocolHandler) NS_METHOD nsFingerHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { @@ -74,8 +76,8 @@ nsFingerHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsFingerHandler::GetURIType(PRInt16 *result) { - *result = URI_NORELATIVE | URI_NOAUTH; +nsFingerHandler::GetProtocolFlags(PRUint32 *result) { + *result = URI_NORELATIVE | URI_NOAUTH | ALLOWS_PROXY; return NS_OK; } @@ -104,6 +106,13 @@ nsFingerHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, NS_IMETHODIMP nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result) +{ + return NewProxiedChannel(url, nsnull, result); +} + +NS_IMETHODIMP +nsFingerHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, + nsIChannel* *result) { nsresult rv; @@ -111,7 +120,7 @@ nsFingerHandler::NewChannel(nsIURI* url, nsIChannel* *result) rv = nsFingerChannel::Create(nsnull, NS_GET_IID(nsIChannel), (void**)&channel); if (NS_FAILED(rv)) return rv; - rv = channel->Init(url); + rv = channel->Init(url, proxyInfo); if (NS_FAILED(rv)) { NS_RELEASE(channel); return rv; diff --git a/netwerk/protocol/finger/src/nsFingerHandler.h b/netwerk/protocol/finger/src/nsFingerHandler.h index 9d07996889d0..367999686b97 100644 --- a/netwerk/protocol/finger/src/nsFingerHandler.h +++ b/netwerk/protocol/finger/src/nsFingerHandler.h @@ -26,7 +26,9 @@ #ifndef nsFingerHandler_h___ #define nsFingerHandler_h___ -#include "nsIProtocolHandler.h" +#include "nsIProxiedProtocolHandler.h" + +class nsIProxyInfo; #define FINGER_PORT 79 @@ -35,11 +37,12 @@ { 0x76d6d5d8, 0x1dd2, 0x11b2, \ {0xb3, 0x61, 0x85, 0x0d, 0xdf, 0x15, 0xef, 0x07} } -class nsFingerHandler : public nsIProtocolHandler +class nsFingerHandler : public nsIProxiedProtocolHandler { public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER // nsFingerHandler methods: nsFingerHandler(); diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/netwerk/protocol/ftp/src/nsFTPChannel.cpp index c96f05fb607e..6c22134ecbd3 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -97,12 +97,13 @@ NS_IMPL_THREADSAFE_ISUPPORTS9(nsFTPChannel, nsICacheListener); nsresult -nsFTPChannel::Init(nsIURI* uri, nsICacheSession* session) +nsFTPChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo, nsICacheSession* session) { nsresult rv = NS_OK; // setup channel state mURL = uri; + mProxyInfo = proxyInfo; rv = mURL->GetHost(getter_Copies(mHost)); if (NS_FAILED(rv)) return rv; @@ -327,7 +328,8 @@ nsFTPChannel::SetupState() mPrompter, mAuthPrompter, mFTPEventSink, - mCacheEntry); + mCacheEntry, + mProxyInfo); if (NS_FAILED(rv)) return rv; (void) mFTPState->SetWriteStream(mUploadStream); diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.h b/netwerk/protocol/ftp/src/nsFTPChannel.h index 79c83499e2a3..72da8af1f1cf 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -44,6 +44,7 @@ #include "nsIAuthPrompt.h" #include "nsIFTPChannel.h" #include "nsIUploadChannel.h" +#include "nsIProxyInfo.h" #include "nsICacheService.h" #include "nsICacheEntryDescriptor.h" @@ -86,7 +87,9 @@ public: Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); // initializes the channel. - nsresult Init(nsIURI* uri, nsICacheSession* session); + nsresult Init(nsIURI* uri, + nsIProxyInfo* proxyInfo, + nsICacheSession* session); nsresult SetupState(); nsresult GenerateCacheKey(nsACString &cacheKey); @@ -129,7 +132,7 @@ protected: nsCOMPtr mCacheSession; nsCOMPtr mCacheEntry; - + nsCOMPtr mProxyInfo; }; #endif /* nsFTPChannel_h___ */ diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index d64127b42d57..3d94e77fc788 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -543,7 +543,7 @@ nsFtpState::EstablishControlConnection() // if we succeed, return. Otherwise, we need to // create a transport - rv = mControlConnection->Connect(); + rv = mControlConnection->Connect(mProxyInfo); if (NS_SUCCEEDED(rv)) return rv; } @@ -572,7 +572,7 @@ nsFtpState::EstablishControlConnection() // Must do it this way 'cuz the channel intercepts the progress notifications. (void) mControlConnection->SetStreamListener(NS_STATIC_CAST(nsIStreamListener*, this)); - return mControlConnection->Connect(); + return mControlConnection->Connect(mProxyInfo); } void @@ -1463,10 +1463,10 @@ nsFtpState::R_pasv() { // now we know where to connect our data channel nsCOMPtr sts = do_GetService(kSocketTransportServiceCID, &rv); - + rv = sts->CreateTransport(hostStr, port, - nsnull, -1, + mProxyInfo, FTP_DATA_CHANNEL_SEG_SIZE, FTP_DATA_CHANNEL_MAX_SIZE, getter_AddRefs(mDPipe)); // the data channel @@ -1676,7 +1676,8 @@ nsFtpState::Init(nsIFTPChannel* aChannel, nsIPrompt* aPrompter, nsIAuthPrompt* aAuthPrompter, nsIFTPEventSink* sink, - nsICacheEntryDescriptor* cacheEntry) + nsICacheEntryDescriptor* cacheEntry, + nsIProxyInfo* proxyInfo) { nsresult rv = NS_OK; @@ -1685,6 +1686,7 @@ nsFtpState::Init(nsIFTPChannel* aChannel, mFTPEventSink = sink; mAuthPrompter = aAuthPrompter; mCacheEntry = cacheEntry; + mProxyInfo = proxyInfo; // parameter validation NS_ASSERTION(aChannel, "FTP: needs a channel"); @@ -1918,6 +1920,7 @@ nsFtpState::StopProcessing() { mPrompter = 0; mAuthPrompter = 0; mChannel = 0; + mProxyInfo = 0; return NS_OK; } diff --git a/netwerk/protocol/ftp/src/nsFtpConnectionThread.h b/netwerk/protocol/ftp/src/nsFtpConnectionThread.h index bc1a75cc6c27..34bae0a063cd 100644 --- a/netwerk/protocol/ftp/src/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/src/nsFtpConnectionThread.h @@ -43,6 +43,7 @@ #include "nsIPrompt.h" #include "nsIAuthPrompt.h" #include "nsITransport.h" +#include "nsIProxyInfo.h" #include "nsFtpControlConnection.h" @@ -98,7 +99,8 @@ public: nsIPrompt *aPrompter, nsIAuthPrompt *aAuthPrompter, nsIFTPEventSink *sink, - nsICacheEntryDescriptor* cacheEntry); + nsICacheEntryDescriptor* cacheEntry, + nsIProxyInfo* proxyInfo); // use this to provide a stream to be written to the server. nsresult SetWriteStream(nsIInputStream* aInStream); @@ -162,6 +164,7 @@ private: // ****** consumer vars nsCOMPtr mChannel; // our owning FTP channel we pass through our events + nsCOMPtr mProxyInfo; // ****** connection cache vars PRInt32 mServerType; // What kind of server are we talking to diff --git a/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp b/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp index cc4b87b04cc1..d9902f258fce 100644 --- a/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp +++ b/netwerk/protocol/ftp/src/nsFtpControlConnection.cpp @@ -126,7 +126,7 @@ nsFtpControlConnection::IsAlive() return isAlive; } nsresult -nsFtpControlConnection::Connect() +nsFtpControlConnection::Connect(nsIProxyInfo* proxyInfo) { nsresult rv; @@ -134,9 +134,10 @@ nsFtpControlConnection::Connect() nsCOMPtr transport; // build our own nsCOMPtr sts = do_GetService(kSocketTransportServiceCID, &rv); + rv = sts->CreateTransport(mHost, mPort, - nsnull, -1, + proxyInfo, FTP_COMMAND_CHANNEL_SEG_SIZE, FTP_COMMAND_CHANNEL_MAX_SIZE, getter_AddRefs(mCPipe)); // the command transport diff --git a/netwerk/protocol/ftp/src/nsFtpControlConnection.h b/netwerk/protocol/ftp/src/nsFtpControlConnection.h index 43129e19d179..8152efadf693 100644 --- a/netwerk/protocol/ftp/src/nsFtpControlConnection.h +++ b/netwerk/protocol/ftp/src/nsFtpControlConnection.h @@ -33,6 +33,8 @@ #include "nsIOutputStream.h" #include "nsAutoLock.h" +class nsIProxyInfo; + class nsFtpControlConnection : public nsIStreamListener { public: @@ -43,7 +45,7 @@ public: nsFtpControlConnection(const char* host, PRUint32 port); virtual ~nsFtpControlConnection(); - nsresult Connect(); + nsresult Connect(nsIProxyInfo* proxyInfo); nsresult Disconnect(nsresult status); nsresult Write(nsCString& command, PRBool suspend); diff --git a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp index d451e08f7397..2cf4dd00c8d4 100644 --- a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.cpp @@ -88,7 +88,9 @@ nsFtpProtocolHandler::~nsFtpProtocolHandler() { mIOSvc = 0; } -NS_IMPL_THREADSAFE_ISUPPORTS1(nsFtpProtocolHandler, nsIProtocolHandler); +NS_IMPL_THREADSAFE_ISUPPORTS2(nsFtpProtocolHandler, + nsIProtocolHandler, + nsIProxiedProtocolHandler); nsresult nsFtpProtocolHandler::Init() { @@ -138,9 +140,9 @@ nsFtpProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsFtpProtocolHandler::GetURIType(PRInt16 *result) +nsFtpProtocolHandler::GetProtocolFlags(PRUint32 *result) { - *result = URI_STD; + *result = URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP; return NS_OK; } @@ -162,6 +164,12 @@ nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, NS_IMETHODIMP nsFtpProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result) +{ + return NewProxiedChannel(url, nsnull, result); +} + +NS_IMETHODIMP +nsFtpProtocolHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, nsIChannel* *result) { nsresult rv = NS_OK; @@ -179,7 +187,7 @@ nsFtpProtocolHandler::NewChannel(nsIURI* url, nsIChannel* *result) if (mCacheSession) rv = mCacheSession->SetDoomEntriesIfExpired(PR_TRUE); - rv = channel->Init(url, mCacheSession); + rv = channel->Init(url, proxyInfo, mCacheSession); if (NS_FAILED(rv)) { PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFtpProtocolHandler::NewChannel() FAILED\n")); return rv; diff --git a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.h b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.h index 5217a2fadbaf..6a1b72df5cb3 100644 --- a/netwerk/protocol/ftp/src/nsFtpProtocolHandler.h +++ b/netwerk/protocol/ftp/src/nsFtpProtocolHandler.h @@ -24,7 +24,7 @@ #define nsFtpProtocolHandler_h___ #include "nsIServiceManager.h" -#include "nsIProtocolHandler.h" +#include "nsIProxiedProtocolHandler.h" #include "nsHashtable.h" #include "nsIIOService.h" #include "nsIThreadPool.h" @@ -36,10 +36,11 @@ #define NS_FTPPROTOCOLHANDLER_CID \ { 0x25029490, 0xf132, 0x11d2, { 0x95, 0x88, 0x0, 0x80, 0x5f, 0x36, 0x9f, 0x95 } } -class nsFtpProtocolHandler : public nsIProtocolHandler{ +class nsFtpProtocolHandler : public nsIProxiedProtocolHandler { public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER // nsFtpProtocolHandler methods: nsFtpProtocolHandler(); diff --git a/netwerk/protocol/gopher/src/nsGopherChannel.cpp b/netwerk/protocol/gopher/src/nsGopherChannel.cpp index df4eb99a883b..b11a000818c3 100644 --- a/netwerk/protocol/gopher/src/nsGopherChannel.cpp +++ b/netwerk/protocol/gopher/src/nsGopherChannel.cpp @@ -75,7 +75,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS4(nsGopherChannel, nsIRequestObserver); nsresult -nsGopherChannel::Init(nsIURI* uri) +nsGopherChannel::Init(nsIURI* uri, nsIProxyInfo* proxyInfo) { nsresult rv; @@ -84,6 +84,7 @@ nsGopherChannel::Init(nsIURI* uri) return NS_ERROR_MALFORMED_URI; mUrl = uri; + mProxyInfo = proxyInfo; nsXPIDLCString buffer; @@ -244,8 +245,7 @@ nsGopherChannel::Open(nsIInputStream **_retval) rv = socketService->CreateTransport(mHost, mPort, - nsnull, - -1, + mProxyInfo, BUFFER_SEG_SIZE, BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); @@ -284,8 +284,7 @@ nsGopherChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports *ctxt) rv = socketService->CreateTransport(mHost, mPort, - nsnull, - -1, + mProxyInfo, BUFFER_SEG_SIZE, BUFFER_MAX_SIZE, getter_AddRefs(mTransport)); @@ -634,4 +633,4 @@ nsGopherChannel::SendRequest(nsITransport* aTransport) 0, mRequest.Length(), 0, this, nsnull); return rv; -} +} \ No newline at end of file diff --git a/netwerk/protocol/gopher/src/nsGopherChannel.h b/netwerk/protocol/gopher/src/nsGopherChannel.h index 766762c9e9ba..7194f5385ed8 100644 --- a/netwerk/protocol/gopher/src/nsGopherChannel.h +++ b/netwerk/protocol/gopher/src/nsGopherChannel.h @@ -38,6 +38,7 @@ #include "nsIProxy.h" #include "nsIStreamListener.h" #include "nsITransport.h" +#include "nsIProxyInfo.h" class nsGopherChannel : public nsIChannel, public nsIStreamListener { @@ -56,7 +57,7 @@ public: static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); - nsresult Init(nsIURI* uri); + nsresult Init(nsIURI* uri, nsIProxyInfo* proxyInfo); protected: nsCOMPtr mOriginalURI; @@ -82,6 +83,7 @@ protected: nsCOMPtr mResponseContext; nsCOMPtr mTransport; nsCOMPtr mTransportRequest; + nsCOMPtr mProxyInfo; nsresult mStatus; nsresult SendRequest(nsITransport* aTransport); diff --git a/netwerk/protocol/gopher/src/nsGopherHandler.cpp b/netwerk/protocol/gopher/src/nsGopherHandler.cpp index 06f413c1d009..ed3486d5af3b 100644 --- a/netwerk/protocol/gopher/src/nsGopherHandler.cpp +++ b/netwerk/protocol/gopher/src/nsGopherHandler.cpp @@ -61,7 +61,9 @@ nsGopherHandler::~nsGopherHandler() { PR_LOG(gGopherLog, PR_LOG_ALWAYS, ("~nsGopherHandler() called")); } -NS_IMPL_THREADSAFE_ISUPPORTS1(nsGopherHandler, nsIProtocolHandler); +NS_IMPL_THREADSAFE_ISUPPORTS2(nsGopherHandler, + nsIProxiedProtocolHandler, + nsIProtocolHandler); NS_METHOD nsGopherHandler::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult) { @@ -91,8 +93,8 @@ nsGopherHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsGopherHandler::GetURIType(PRInt16 *result) { - *result = URI_NORELATIVE; +nsGopherHandler::GetProtocolFlags(PRUint32 *result) { + *result = URI_NORELATIVE | ALLOWS_PROXY | ALLOWS_PROXY_HTTP; return NS_OK; } @@ -117,7 +119,8 @@ nsGopherHandler::NewURI(const char *aSpec, nsIURI *aBaseURI, } NS_IMETHODIMP -nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result) +nsGopherHandler::NewProxiedChannel(nsIURI* url, nsIProxyInfo* proxyInfo, + nsIChannel* *result) { nsresult rv; nsGopherChannel* channel; @@ -125,7 +128,7 @@ nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result) (void**)&channel); if (NS_FAILED(rv)) return rv; - rv = channel->Init(url); + rv = channel->Init(url, proxyInfo); if (NS_FAILED(rv)) { return rv; } @@ -134,6 +137,12 @@ nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result) return rv; } +NS_IMETHODIMP +nsGopherHandler::NewChannel(nsIURI* url, nsIChannel* *result) +{ + return NewProxiedChannel(url, nsnull, result); +} + NS_IMETHODIMP nsGopherHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) { diff --git a/netwerk/protocol/gopher/src/nsGopherHandler.h b/netwerk/protocol/gopher/src/nsGopherHandler.h index d29d90817648..7edc551d852d 100644 --- a/netwerk/protocol/gopher/src/nsGopherHandler.h +++ b/netwerk/protocol/gopher/src/nsGopherHandler.h @@ -23,7 +23,7 @@ #ifndef nsGopherHandler_h___ #define nsGopherHandler_h___ -#include "nsIProtocolHandler.h" +#include "nsIProxiedProtocolHandler.h" #include "nsIProtocolProxyService.h" #include "nsString.h" #include "nsCOMPtr.h" @@ -36,10 +36,11 @@ { 0x44588c1f, 0x2ce8, 0x4ad8, \ {0x9b, 0x16, 0xdf, 0xb9, 0xd9, 0xd5, 0x13, 0xa7} } -class nsGopherHandler : public nsIProtocolHandler { +class nsGopherHandler : public nsIProxiedProtocolHandler { public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER // nsGopherHandler methods: nsGopherHandler(); diff --git a/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl b/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl index 25394cfc285f..f6d8551c1dca 100644 --- a/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl +++ b/netwerk/protocol/http/public/nsIHttpProtocolHandler.idl @@ -22,24 +22,11 @@ * Darin Fisher */ -#include "nsIProtocolHandler.idl" +#include "nsIProxiedProtocolHandler.idl" [scriptable, uuid(122c91c0-2485-40ba-89c9-b895934921bc)] -interface nsIHttpProtocolHandler : nsIProtocolHandler +interface nsIHttpProtocolHandler : nsIProxiedProtocolHandler { - /** - * Constructs a new http proxy channel. - * - * @param uri - the desired request-URI (eg. ftp://ftp.mozilla.org/) - * @param proxyHost - the proxy hostname - * @param proxyPort - the proxy port - * @param proxyType - the proxy type (usually "http" or "socks") - */ - nsIChannel newProxyChannel(in nsIURI uri, - in string proxyHost, - in long proxyPort, - in string proxyType); - /** * Get the HTTP advertised user agent string. */ diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index bb2993fb5792..1df3d1641803 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -103,9 +103,7 @@ nsHttpChannel::~nsHttpChannel() nsresult nsHttpChannel::Init(nsIURI *uri, PRUint8 caps, - const char *proxyHost, - PRInt32 proxyPort, - const char *proxyType) + nsIProxyInfo *proxyInfo) { nsresult rv; @@ -141,8 +139,7 @@ nsHttpChannel::Init(nsIURI *uri, LOG(("host=%s port=%d\n", host.get(), port)); mConnectionInfo = new nsHttpConnectionInfo(host, port, - proxyHost, proxyPort, - proxyType, usingSSL); + proxyInfo, usingSSL); if (!mConnectionInfo) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(mConnectionInfo); @@ -172,10 +169,10 @@ nsHttpChannel::Init(nsIURI *uri, rv = mRequestHead.SetHeader(nsHttp::Host, hostLine); if (NS_FAILED(rv)) return rv; - PRBool useProxy = (proxyHost && !PL_strcmp(proxyType, "http")); - - rv = nsHttpHandler::get()->AddStandardRequestHeaders(&mRequestHead.Headers(), - caps, useProxy); + rv = nsHttpHandler::get()-> + AddStandardRequestHeaders(&mRequestHead.Headers(), + caps, + mConnectionInfo->UsingHttpProxy()); if (NS_FAILED(rv)) return rv; // check to see if authorization headers should be included @@ -300,13 +297,11 @@ nsHttpChannel::SetupTransaction() NS_ADDREF(mTransaction); // use the URI path if not proxying (transparent proxying such as SSL proxy - // or socks does not count here). + // does not count here). nsXPIDLCString requestURIStr; const char* requestURI; - if (!mConnectionInfo->ProxyHost() || - mConnectionInfo->UsingSSL() || - !PL_strcmp(mConnectionInfo->ProxyType(), "socks") || - !PL_strcmp(mConnectionInfo->ProxyType(), "socks4")) { + if (mConnectionInfo->UsingSSL() || + !mConnectionInfo->UsingHttpProxy()) { rv = mURI->GetPath(getter_Copies(requestURIStr)); if (NS_FAILED(rv)) return rv; requestURI = requestURIStr.get(); @@ -1055,10 +1050,12 @@ nsHttpChannel::ProcessRedirection(PRUint32 redirectType) else proxyPort = 80; + nsCOMPtr pi; + rv = NS_NewProxyInfo("http", location, proxyPort, getter_AddRefs(pi)); + // talk to the http handler directly for this case rv = nsHttpHandler::get()-> - NewProxyChannel(mURI, location, proxyPort, "http", - getter_AddRefs(newChannel)); + NewProxiedChannel(mURI, pi, getter_AddRefs(newChannel)); if (NS_FAILED(rv)) return rv; } else { @@ -1509,8 +1506,7 @@ nsHttpChannel::AddAuthorizationHeaders() // check if proxy credentials should be sent const char *proxyHost = mConnectionInfo->ProxyHost(); - const char *proxyType = mConnectionInfo->ProxyType(); - if (proxyHost && !PL_strcmp(proxyType, "http")) { + if (proxyHost) { rv = authCache->GetCredentialsForPath(proxyHost, mConnectionInfo->ProxyPort(), nsnull, realm, creds); diff --git a/netwerk/protocol/http/src/nsHttpChannel.h b/netwerk/protocol/http/src/nsHttpChannel.h index 03c8c4b454b2..6acae013f312 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.h +++ b/netwerk/protocol/http/src/nsHttpChannel.h @@ -42,11 +42,12 @@ #include "nsIUploadChannel.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsHttpConnection.h" class nsHttpTransaction; -class nsHttpConnectionInfo; class nsHttpResponseHead; class nsIHttpAuthenticator; +class nsIProxyInfo; //----------------------------------------------------------------------------- // nsHttpChannel @@ -78,9 +79,7 @@ public: nsresult Init(nsIURI *uri, PRUint8 capabilities, - const char *proxyHost=0, - PRInt32 proxyPort=-1, - const char *proxyType=0); + nsIProxyInfo* proxyInfo); private: nsresult Connect(PRBool firstTime = PR_TRUE); diff --git a/netwerk/protocol/http/src/nsHttpConnection.cpp b/netwerk/protocol/http/src/nsHttpConnection.cpp index 54757a7b5c5e..8b18869083e5 100644 --- a/netwerk/protocol/http/src/nsHttpConnection.cpp +++ b/netwerk/protocol/http/src/nsHttpConnection.cpp @@ -354,11 +354,8 @@ nsHttpConnection::ActivateConnection() if (NS_FAILED(rv)) return rv; // need to handle SSL proxy CONNECT if this is the first time. - // unless its SOCKS. if (mConnectionInfo->UsingSSL() && - mConnectionInfo->ProxyHost() && - PL_strcmp(mConnectionInfo->ProxyType(), "socks") && - PL_strcmp(mConnectionInfo->ProxyType(), "socks4")) { + mConnectionInfo->UsingHttpProxy()) { rv = SetupSSLProxyConnect(); if (NS_FAILED(rv)) return rv; } @@ -458,33 +455,23 @@ nsHttpConnection::CreateTransport() if (NS_FAILED(rv)) return rv; // configure the socket type based on the connection type requested. - const char *types[3] = {0,0,0}; - PRUint32 count = 0; - - if (!PL_strcasecmp(mConnectionInfo->ProxyType(), "socks")) { - types[count] = "socks"; - count++; - } - - if (!PL_strcasecmp(mConnectionInfo->ProxyType(), "socks4")) { - types[count] = "socks4"; - count++; - } + const char* type = nsnull; if (mConnectionInfo->UsingSSL()) { - types[count] = "ssl"; - count++; + if (mConnectionInfo->UsingHttpProxy()) + type = "tlsstepup"; + else + type = "ssl"; } nsCOMPtr transport; - rv = sts->CreateTransportOfTypes(count, types, - mConnectionInfo->Host(), - mConnectionInfo->Port(), - mConnectionInfo->ProxyHost(), - mConnectionInfo->ProxyPort(), - NS_HTTP_SEGMENT_SIZE, - NS_HTTP_BUFFER_SIZE, - getter_AddRefs(transport)); + rv = sts->CreateTransportOfType(type, + mConnectionInfo->Host(), + mConnectionInfo->Port(), + mConnectionInfo->ProxyInfo(), + NS_HTTP_SEGMENT_SIZE, + NS_HTTP_BUFFER_SIZE, + getter_AddRefs(transport)); if (NS_FAILED(rv)) return rv; // the transport has better be a socket transport !! diff --git a/netwerk/protocol/http/src/nsHttpConnection.h b/netwerk/protocol/http/src/nsHttpConnection.h index 05593eaa34ee..2c0b85198f73 100644 --- a/netwerk/protocol/http/src/nsHttpConnection.h +++ b/netwerk/protocol/http/src/nsHttpConnection.h @@ -33,6 +33,7 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsIEventQueue.h" #include "nsIInputStream.h" +#include "nsIProxyInfo.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" #include "plstr.h" @@ -148,20 +149,17 @@ class nsHttpConnectionInfo : public nsISupports public: NS_DECL_ISUPPORTS - nsHttpConnectionInfo(const char *host, PRInt32 port=-1, - const char *proxyHost=0, PRInt32 proxyPort=-1, - const char *proxyType=0, PRBool usingSSL=0) - : mProxyPort(proxyPort) - , mUsingSSL(usingSSL) + nsHttpConnectionInfo(const char *host, PRInt32 port, + nsIProxyInfo* proxyInfo, + PRBool usingSSL=PR_FALSE) + : mProxyInfo(proxyInfo) + , mUsingSSL(usingSSL) { LOG(("Creating nsHttpConnectionInfo @%x\n", this)); NS_INIT_ISUPPORTS(); - if (proxyHost) - mProxyHost.Adopt(nsCRT::strdup(proxyHost)); - if (proxyType) - mProxyType.Adopt(nsCRT::strdup(proxyType)); + mUsingHttpProxy = (proxyInfo && !nsCRT::strcmp(proxyInfo->Type(), "http")); SetOriginServer(host, port); } @@ -170,7 +168,7 @@ public: { if (host) mHost.Adopt(nsCRT::strdup(host)); - mPort = port == -1 ? DefaultPort(): port; + mPort = port == -1 ? DefaultPort() : port; return NS_OK; } @@ -180,36 +178,40 @@ public: LOG(("Destroying nsHttpConnectionInfo @%x\n", this)); } + const char *ProxyHost() const { return mProxyInfo ? mProxyInfo->Host() : nsnull; } + PRInt32 ProxyPort() const { return mProxyInfo ? mProxyInfo->Port() : -1; } + const char *ProxyType() const { return mProxyInfo ? mProxyInfo->Type() : nsnull; } + // Compare this connection info to another... // Two connections are 'equal' if they end up talking the same // protocol to the same server. This is needed to properly manage // persistent connections to proxies + // Note that we don't care about transparent proxies - + // it doesn't matter if we're talking via socks or not, since + // a request will end up at the same host. PRBool Equals(const nsHttpConnectionInfo *info) { - // if its a host independent proxy, then compare the proxy - // servers. - if ((info->mProxyHost.get() || mProxyHost.get()) && - !mUsingSSL && - PL_strcasecmp(mProxyType, "socks") != 0 && - PL_strcasecmp(mProxyType, "socks4") != 0) { - return (!PL_strcasecmp(info->mProxyHost, mProxyHost) && - !PL_strcasecmp(info->mProxyType, mProxyType) && - info->mProxyPort == mProxyPort && - info->mUsingSSL == mUsingSSL); - } + // Strictly speaking, we could talk to a proxy on the same port + // and reuse the connection. Its not worth the extra strcmp. + if ((info->mUsingHttpProxy != mUsingHttpProxy) || + (info->mUsingSSL != mUsingSSL)) + return PR_FALSE; + + // if its a proxy, then compare the proxy servers. + if (mUsingHttpProxy && !mUsingSSL) + return (!PL_strcasecmp(info->ProxyHost(), ProxyHost()) && + info->ProxyPort() == ProxyPort()); // otherwise, just check the hosts return (!PL_strcasecmp(info->mHost, mHost) && - info->mPort == mPort && - info->mUsingSSL == mUsingSSL); + info->mPort == mPort); } const char *Host() { return mHost; } PRInt32 Port() { return mPort; } - const char *ProxyHost() { return mProxyHost; } - PRInt32 ProxyPort() { return mProxyPort; } - const char *ProxyType() { return mProxyType; } + nsIProxyInfo *ProxyInfo() { return mProxyInfo; } + PRBool UsingHttpProxy() { return mUsingHttpProxy; } PRBool UsingSSL() { return mUsingSSL; } PRInt32 DefaultPort() { return mUsingSSL ? 443 : 80; } @@ -217,9 +219,8 @@ public: private: nsXPIDLCString mHost; PRInt32 mPort; - nsXPIDLCString mProxyHost; - PRInt32 mProxyPort; - nsXPIDLCString mProxyType; + nsCOMPtr mProxyInfo; + PRPackedBool mUsingHttpProxy; PRPackedBool mUsingSSL; }; diff --git a/netwerk/protocol/http/src/nsHttpHandler.cpp b/netwerk/protocol/http/src/nsHttpHandler.cpp index 4ab433b5cf27..6abf79263619 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -1519,8 +1519,9 @@ nsHttpHandler::SetAcceptEncodings(const char *aAcceptEncodings) // nsHttpHandler::nsISupports //----------------------------------------------------------------------------- -NS_IMPL_THREADSAFE_ISUPPORTS4(nsHttpHandler, +NS_IMPL_THREADSAFE_ISUPPORTS5(nsHttpHandler, nsIHttpProtocolHandler, + nsIProxiedProtocolHandler, nsIProtocolHandler, nsIObserver, nsISupportsWeakReference) @@ -1542,9 +1543,9 @@ nsHttpHandler::GetDefaultPort(PRInt32 *aDefaultPort) } NS_IMETHODIMP -nsHttpHandler::GetURIType(PRInt16 *result) +nsHttpHandler::GetProtocolFlags(PRUint32 *result) { - *result = URI_STD; + *result = URI_STD | ALLOWS_PROXY | ALLOWS_PROXY_HTTP; return NS_OK; } @@ -1587,11 +1588,9 @@ nsHttpHandler::NewChannel(nsIURI *uri, nsIChannel **result) } } - rv = NewProxyChannel(uri, - nsnull, - -1, - nsnull, - result); + rv = NewProxiedChannel(uri, + nsnull, + result); return rv; } @@ -1604,20 +1603,18 @@ nsHttpHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_retval) } //----------------------------------------------------------------------------- -// nsHttpHandler::nsIHttpProtocolHandler +// nsHttpHandler::nsIProxiedProtocolHandler //----------------------------------------------------------------------------- - + NS_IMETHODIMP -nsHttpHandler::NewProxyChannel(nsIURI *uri, - const char *proxyHost, - PRInt32 proxyPort, - const char *proxyType, - nsIChannel **result) +nsHttpHandler::NewProxiedChannel(nsIURI *uri, + nsIProxyInfo* proxyInfo, + nsIChannel **result) { nsHttpChannel *httpChannel = nsnull; - LOG(("nsHttpHandler::NewProxyChannel [proxy=%s:%d type=%s]\n", - proxyHost, proxyPort, proxyType)); + LOG(("nsHttpHandler::NewProxiedChannel [proxyInfo=%p]\n", + proxyInfo)); NS_NEWXPCOM(httpChannel, nsHttpChannel); if (!httpChannel) @@ -1626,9 +1623,7 @@ nsHttpHandler::NewProxyChannel(nsIURI *uri, nsresult rv = httpChannel->Init(uri, mCapabilities, - proxyHost, - proxyPort, - proxyType); + proxyInfo); if (NS_SUCCEEDED(rv)) rv = httpChannel-> @@ -1638,6 +1633,10 @@ nsHttpHandler::NewProxyChannel(nsIURI *uri, return rv; } +//----------------------------------------------------------------------------- +// nsHttpHandler::nsIHttpProtocolHandler +//----------------------------------------------------------------------------- + NS_IMETHODIMP nsHttpHandler::GetUserAgent(char **aUserAgent) { diff --git a/netwerk/protocol/http/src/nsHttpHandler.h b/netwerk/protocol/http/src/nsHttpHandler.h index 3eff61e643af..09607770a720 100644 --- a/netwerk/protocol/http/src/nsHttpHandler.h +++ b/netwerk/protocol/http/src/nsHttpHandler.h @@ -61,6 +61,7 @@ class nsHttpHandler : public nsIHttpProtocolHandler public: NS_DECL_ISUPPORTS NS_DECL_NSIPROTOCOLHANDLER + NS_DECL_NSIPROXIEDPROTOCOLHANDLER NS_DECL_NSIHTTPPROTOCOLHANDLER NS_DECL_NSIOBSERVER diff --git a/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp b/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp index e701d7790f63..c7be2c81e561 100644 --- a/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp +++ b/netwerk/protocol/jar/src/nsJARProtocolHandler.cpp @@ -112,7 +112,7 @@ nsJARProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsJARProtocolHandler::GetURIType(PRInt16 *result) +nsJARProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; /* Although jar uris have their own concept of relative urls diff --git a/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp b/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp index fa0100232dc5..74e034a5e06e 100644 --- a/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp +++ b/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp @@ -96,7 +96,7 @@ nsKeywordProtocolHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsKeywordProtocolHandler::GetURIType(PRInt16 *result) { +nsKeywordProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; } diff --git a/netwerk/protocol/res/src/nsResProtocolHandler.cpp b/netwerk/protocol/res/src/nsResProtocolHandler.cpp index e075b2757f7d..4214fd0772aa 100644 --- a/netwerk/protocol/res/src/nsResProtocolHandler.cpp +++ b/netwerk/protocol/res/src/nsResProtocolHandler.cpp @@ -167,7 +167,7 @@ nsResProtocolHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsResProtocolHandler::GetURIType(PRInt16 *result) +nsResProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_STD; return NS_OK; diff --git a/netwerk/protocol/theme/src/nsThemeHandler.cpp b/netwerk/protocol/theme/src/nsThemeHandler.cpp index d4c4ee9666c0..e0b270298ccd 100644 --- a/netwerk/protocol/theme/src/nsThemeHandler.cpp +++ b/netwerk/protocol/theme/src/nsThemeHandler.cpp @@ -121,7 +121,7 @@ nsThemeHandler::GetDefaultPort(PRInt32 *result) } NS_IMETHODIMP -nsThemeHandler::GetURIType(PRInt16 *result) +nsThemeHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; diff --git a/netwerk/protocol/viewsource/src/nsViewSourceHandler.cpp b/netwerk/protocol/viewsource/src/nsViewSourceHandler.cpp index 52217519043b..f52bb2e707ca 100644 --- a/netwerk/protocol/viewsource/src/nsViewSourceHandler.cpp +++ b/netwerk/protocol/viewsource/src/nsViewSourceHandler.cpp @@ -74,7 +74,7 @@ nsViewSourceHandler::GetDefaultPort(PRInt32 *result) { } NS_IMETHODIMP -nsViewSourceHandler::GetURIType(PRInt16 *result) { +nsViewSourceHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_NORELATIVE | URI_NOAUTH; return NS_OK; } diff --git a/netwerk/test/Makefile.in b/netwerk/test/Makefile.in index 3c6b29ce1bce..b63c38abc84a 100644 --- a/netwerk/test/Makefile.in +++ b/netwerk/test/Makefile.in @@ -32,7 +32,6 @@ REQUIRES = xpcom string necko nkcache timer cookie dbm util SHARED_LIBRARY_LIBS = $(DIST)/lib/libmozdbm_s.$(LIB_SUFFIX) CPPSRCS = \ - TestOverlappedIO.cpp \ TestSocketIO.cpp \ TestSocketInput.cpp \ TestSocketTransport.cpp \ diff --git a/netwerk/test/TestSocketIO.cpp b/netwerk/test/TestSocketIO.cpp index 5fbcff5a5dcf..017eec9861d5 100644 --- a/netwerk/test/TestSocketIO.cpp +++ b/netwerk/test/TestSocketIO.cpp @@ -311,7 +311,7 @@ main(int argc, char* argv[]) // Create the socket transport... nsCOMPtr transport; - rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, getter_AddRefs(transport)); + rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, getter_AddRefs(transport)); if (NS_FAILED(rv)) { NS_WARNING("failed to create: socket transport!"); return rv; diff --git a/netwerk/test/TestSocketInput.cpp b/netwerk/test/TestSocketInput.cpp index 3cf79ec906cf..6f786f530932 100644 --- a/netwerk/test/TestSocketInput.cpp +++ b/netwerk/test/TestSocketInput.cpp @@ -163,7 +163,7 @@ main(int argc, char* argv[]) nsITransport* transport; - rv = sts->CreateTransport(hostName, port, nsnull, -1, 0, 0, &transport); + rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, &transport); if (NS_SUCCEEDED(rv)) { nsCOMPtr request; transport->AsyncRead(nsnull, new InputTestConsumer, 0, -1, 0, getter_AddRefs(request)); diff --git a/netwerk/test/TestSocketTransport.cpp b/netwerk/test/TestSocketTransport.cpp index 4d4ba2243a59..96d2062a5c1b 100644 --- a/netwerk/test/TestSocketTransport.cpp +++ b/netwerk/test/TestSocketTransport.cpp @@ -305,7 +305,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort, nsCOMPtr sts = do_GetService(kSocketTransportServiceCID, &rv); if (NS_SUCCEEDED(rv)) { - rv = sts->CreateTransport(aHostName, aPort, nsnull, -1, 0, 0, &mTransport); + rv = sts->CreateTransport(aHostName, aPort, nsnull, 0, 0, &mTransport); if (NS_SUCCEEDED(rv)) { // Set up the notification callbacks to provide a progress event sink. // That way we exercise the progress notification proxy code. diff --git a/rdf/chrome/src/nsChromeProtocolHandler.cpp b/rdf/chrome/src/nsChromeProtocolHandler.cpp index 5aa309d4c7b7..fc0cc58be90d 100644 --- a/rdf/chrome/src/nsChromeProtocolHandler.cpp +++ b/rdf/chrome/src/nsChromeProtocolHandler.cpp @@ -525,7 +525,7 @@ nsChromeProtocolHandler::AllowPort(PRInt32 port, const char *scheme, PRBool *_re } NS_IMETHODIMP -nsChromeProtocolHandler::GetURIType(PRInt16 *result) +nsChromeProtocolHandler::GetProtocolFlags(PRUint32 *result) { *result = URI_STD; return NS_OK; diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp index ebfd6bed2d3d..bb54b764880a 100644 --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -302,7 +302,7 @@ PRBool nsExternalProtocolHandler::HaveProtocolHandler(nsIURI * aURI) return haveHandler; } -NS_IMETHODIMP nsExternalProtocolHandler::GetURIType(PRInt16 *aUritype) +NS_IMETHODIMP nsExternalProtocolHandler::GetProtocolFlags(PRUint32 *aUritype) { // Make it norelative since it is a simple uri *aUritype = URI_NORELATIVE; diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index 96f93747d1e4..1f3b17e2c94e 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -781,6 +781,8 @@ nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, nsresult err; char buffer[8*1024]; PRUint32 writeCount; + + printf("nsXPInstallManager::OnDataAvailable\n"); if (mCancelled) {