diff --git a/extensions/auth/nsHttpNegotiateAuth.cpp b/extensions/auth/nsHttpNegotiateAuth.cpp index 2b74954a43d..c81e69d0593 100644 --- a/extensions/auth/nsHttpNegotiateAuth.cpp +++ b/extensions/auth/nsHttpNegotiateAuth.cpp @@ -55,7 +55,7 @@ #include "nsHttpNegotiateAuth.h" #include "nsIHttpChannel.h" -#include "nsIHttpChannelInternal.h" +#include "nsIProxiedChannel.h" #include "nsIAuthModule.h" #include "nsIServiceManager.h" #include "nsIPrefService.h" @@ -136,12 +136,12 @@ nsHttpNegotiateAuth::ChallengeReceived(nsIHttpChannel *httpChannel, return NS_ERROR_ABORT; } - nsCOMPtr httpInternal = + nsCOMPtr proxied = do_QueryInterface(httpChannel); - NS_ENSURE_STATE(httpInternal); + NS_ENSURE_STATE(proxied); nsCOMPtr proxyInfo; - httpInternal->GetProxyInfo(getter_AddRefs(proxyInfo)); + proxied->GetProxyInfo(getter_AddRefs(proxyInfo)); NS_ENSURE_STATE(proxyInfo); proxyInfo->GetHost(service); diff --git a/extensions/datetime/nsDateTimeChannel.cpp b/extensions/datetime/nsDateTimeChannel.cpp index 2dd874206ff..ee3f6e34b11 100644 --- a/extensions/datetime/nsDateTimeChannel.cpp +++ b/extensions/datetime/nsDateTimeChannel.cpp @@ -67,11 +67,12 @@ nsDateTimeChannel::~nsDateTimeChannel() { } -NS_IMPL_ISUPPORTS4(nsDateTimeChannel, +NS_IMPL_ISUPPORTS5(nsDateTimeChannel, nsIChannel, nsIRequest, nsIStreamListener, - nsIRequestObserver) + nsIRequestObserver, + nsIProxiedChannel) nsresult nsDateTimeChannel::Init(nsIURI *uri, nsIProxyInfo *proxyInfo) @@ -429,3 +430,16 @@ nsDateTimeChannel::OnTransportStatus(nsITransport *trans, nsresult status, } return NS_OK; } + +//----------------------------------------------------------------------------- +// nsIProxiedChannel methods +//----------------------------------------------------------------------------- + +NS_IMETHODIMP +nsDateTimeChannel::GetProxyInfo(nsIProxyInfo** aProxyInfo) +{ + *aProxyInfo = mProxyInfo; + NS_IF_ADDREF(*aProxyInfo); + return NS_OK; +} + diff --git a/extensions/datetime/nsDateTimeChannel.h b/extensions/datetime/nsDateTimeChannel.h index c22dc0dbc87..5b64136abf0 100644 --- a/extensions/datetime/nsDateTimeChannel.h +++ b/extensions/datetime/nsDateTimeChannel.h @@ -55,12 +55,14 @@ #include "nsIStreamListener.h" #include "nsISocketTransport.h" #include "nsIProxyInfo.h" +#include "nsIProxiedChannel.h" //----------------------------------------------------------------------------- class nsDateTimeChannel : public nsIChannel , public nsIStreamListener , public nsITransportEventSink + , public nsIProxiedChannel { public: NS_DECL_ISUPPORTS @@ -69,6 +71,7 @@ public: NS_DECL_NSISTREAMLISTENER NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSITRANSPORTEVENTSINK + NS_DECL_NSIPROXIEDCHANNEL // nsDateTimeChannel methods: nsDateTimeChannel(); diff --git a/extensions/finger/nsFingerChannel.cpp b/extensions/finger/nsFingerChannel.cpp index de827eaccc0..fae457beb96 100644 --- a/extensions/finger/nsFingerChannel.cpp +++ b/extensions/finger/nsFingerChannel.cpp @@ -71,11 +71,12 @@ nsFingerChannel::~nsFingerChannel() { } -NS_IMPL_ISUPPORTS4(nsFingerChannel, +NS_IMPL_ISUPPORTS5(nsFingerChannel, nsIChannel, nsIRequest, nsIStreamListener, - nsIRequestObserver) + nsIRequestObserver, + nsIProxiedChannel) nsresult nsFingerChannel::Init(nsIURI *uri, nsIProxyInfo *proxyInfo) @@ -452,6 +453,18 @@ nsFingerChannel::OnTransportStatus(nsITransport *trans, nsresult status, return NS_OK; } +//----------------------------------------------------------------------------- +// nsIProxiedChannel methods +//----------------------------------------------------------------------------- + +NS_IMETHODIMP +nsFingerChannel::GetProxyInfo(nsIProxyInfo** aProxyInfo) +{ + *aProxyInfo = mProxyInfo; + NS_IF_ADDREF(*aProxyInfo); + return NS_OK; +} + //----------------------------------------------------------------------------- nsresult diff --git a/extensions/finger/nsFingerChannel.h b/extensions/finger/nsFingerChannel.h index b8019fd944b..0f95480f305 100644 --- a/extensions/finger/nsFingerChannel.h +++ b/extensions/finger/nsFingerChannel.h @@ -56,12 +56,14 @@ #include "nsIStreamListener.h" #include "nsISocketTransport.h" #include "nsIProxyInfo.h" +#include "nsIProxiedChannel.h" //----------------------------------------------------------------------------- class nsFingerChannel : public nsIChannel , public nsIStreamListener , public nsITransportEventSink + , public nsIProxiedChannel { public: NS_DECL_ISUPPORTS @@ -70,6 +72,7 @@ public: NS_DECL_NSISTREAMLISTENER NS_DECL_NSIREQUESTOBSERVER NS_DECL_NSITRANSPORTEVENTSINK + NS_DECL_NSIPROXIEDCHANNEL // nsFingerChannel methods: nsFingerChannel(); diff --git a/netwerk/base/public/Makefile.in b/netwerk/base/public/Makefile.in index 1bfefbc2236..2a1c433181e 100644 --- a/netwerk/base/public/Makefile.in +++ b/netwerk/base/public/Makefile.in @@ -118,6 +118,7 @@ XPIDLSRCS = \ nsPISocketTransportService.idl \ nsIChannelEventSink.idl \ nsINetUtil.idl \ + nsIProxiedChannel.idl \ $(NULL) EXPORTS = \ diff --git a/netwerk/base/public/nsIProxiedChannel.idl b/netwerk/base/public/nsIProxiedChannel.idl new file mode 100644 index 00000000000..dee5ef141ed --- /dev/null +++ b/netwerk/base/public/nsIProxiedChannel.idl @@ -0,0 +1,60 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * 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 networking code. + * + * The Initial Developer of the Original Code is + * Google Inc. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Christian Biesinger + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsISupports.idl" + +interface nsIProxyInfo; + +/** + * An interface for accessing the proxy info that a channel was + * constructed with. + * + * @see nsIProxiedProtocolHandler + */ +[scriptable, uuid(6238f134-8c3f-4354-958f-dfd9d54a4446)] +interface nsIProxiedChannel : nsISupports +{ + /** + * Gets the proxy info the channel was constructed with. null or a + * proxyInfo with type "direct" mean no proxy. + * + * The returned proxy info must not be modified. + */ + readonly attribute nsIProxyInfo proxyInfo; +}; + + diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 8cf9c27e5e8..688ebcb0386 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -77,11 +77,12 @@ PRTimeToSeconds(PRTime t_usec) //----------------------------------------------------------------------------- -NS_IMPL_ISUPPORTS_INHERITED3(nsFtpChannel, +NS_IMPL_ISUPPORTS_INHERITED4(nsFtpChannel, nsBaseChannel, nsIUploadChannel, nsIResumableChannel, - nsIFTPChannel) + nsIFTPChannel, + nsIProxiedChannel) //----------------------------------------------------------------------------- @@ -130,6 +131,15 @@ nsFtpChannel::GetEntityID(nsACString& entityID) return NS_OK; } +//----------------------------------------------------------------------------- +NS_IMETHODIMP +nsFtpChannel::GetProxyInfo(nsIProxyInfo** aProxyInfo) +{ + *aProxyInfo = ProxyInfo(); + NS_IF_ADDREF(*aProxyInfo); + return NS_OK; +} + //----------------------------------------------------------------------------- nsresult diff --git a/netwerk/protocol/ftp/src/nsFTPChannel.h b/netwerk/protocol/ftp/src/nsFTPChannel.h index 1b39e6ed2bd..08beee70cdc 100644 --- a/netwerk/protocol/ftp/src/nsFTPChannel.h +++ b/netwerk/protocol/ftp/src/nsFTPChannel.h @@ -61,6 +61,7 @@ #include "nsIFTPChannel.h" #include "nsIUploadChannel.h" #include "nsIProxyInfo.h" +#include "nsIProxiedChannel.h" #include "nsIResumableChannel.h" #include "nsHashPropertyBag.h" @@ -78,12 +79,14 @@ class nsFtpChannel : public nsBaseChannel, public nsIFTPChannel, public nsIUploadChannel, - public nsIResumableChannel + public nsIResumableChannel, + public nsIProxiedChannel { public: NS_DECL_ISUPPORTS_INHERITED NS_DECL_NSIUPLOADCHANNEL NS_DECL_NSIRESUMABLECHANNEL + NS_DECL_NSIPROXIEDCHANNEL nsFtpChannel(nsIURI *uri, nsIProxyInfo *pi) : mProxyInfo(pi) diff --git a/netwerk/protocol/gopher/src/nsGopherChannel.cpp b/netwerk/protocol/gopher/src/nsGopherChannel.cpp index f03dcf5cd16..79926d24281 100644 --- a/netwerk/protocol/gopher/src/nsGopherChannel.cpp +++ b/netwerk/protocol/gopher/src/nsGopherChannel.cpp @@ -448,6 +448,18 @@ nsGopherContentStream::SendRequest() //----------------------------------------------------------------------------- +NS_IMPL_ISUPPORTS_INHERITED1(nsGopherChannel, + nsBaseChannel, + nsIProxiedChannel) + +NS_IMETHODIMP +nsGopherChannel::GetProxyInfo(nsIProxyInfo** aProxyInfo) +{ + *aProxyInfo = ProxyInfo(); + NS_IF_ADDREF(*aProxyInfo); + return NS_OK; +} + nsresult nsGopherChannel::OpenContentStream(PRBool async, nsIInputStream **result) { diff --git a/netwerk/protocol/gopher/src/nsGopherChannel.h b/netwerk/protocol/gopher/src/nsGopherChannel.h index 8f37fee5254..4cfe9d8f5a0 100644 --- a/netwerk/protocol/gopher/src/nsGopherChannel.h +++ b/netwerk/protocol/gopher/src/nsGopherChannel.h @@ -43,13 +43,17 @@ #include "nsBaseChannel.h" #include "nsIProxyInfo.h" +#include "nsIProxiedChannel.h" -class nsGopherChannel : public nsBaseChannel { +class nsGopherChannel : public nsBaseChannel, public nsIProxiedChannel { public: nsGopherChannel(nsIURI *uri, nsIProxyInfo *pi) : mProxyInfo(pi) { SetURI(uri); } + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_NSIPROXIEDCHANNEL + nsIProxyInfo *ProxyInfo() { return mProxyInfo; } protected: diff --git a/netwerk/protocol/http/public/nsIHttpChannelInternal.idl b/netwerk/protocol/http/public/nsIHttpChannelInternal.idl index d9276c528eb..ac75960058a 100644 --- a/netwerk/protocol/http/public/nsIHttpChannelInternal.idl +++ b/netwerk/protocol/http/public/nsIHttpChannelInternal.idl @@ -45,7 +45,7 @@ interface nsIProxyInfo; * using any feature exposed by this interface, be aware that this interface * will change and you will be broken. You have been warned. */ -[scriptable, uuid(f3764874-ed7e-4873-883c-11d67a4e3638)] +[scriptable, uuid(602e8cf0-c387-4598-9e6c-aa4b1551ed1c)] interface nsIHttpChannelInternal : nsISupports { /** @@ -72,9 +72,4 @@ interface nsIHttpChannelInternal : nsISupports * The cookie header to be parsed. */ void setCookie(in string aCookieHeader); - - /** - * Get the proxy info in use by the channel. - */ - readonly attribute nsIProxyInfo proxyInfo; }; diff --git a/netwerk/protocol/http/src/nsHttpChannel.cpp b/netwerk/protocol/http/src/nsHttpChannel.cpp index fd95bf7535a..5d697061667 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.cpp +++ b/netwerk/protocol/http/src/nsHttpChannel.cpp @@ -3015,6 +3015,7 @@ NS_INTERFACE_MAP_BEGIN(nsHttpChannel) NS_INTERFACE_MAP_ENTRY(nsITransportEventSink) NS_INTERFACE_MAP_ENTRY(nsISupportsPriority) NS_INTERFACE_MAP_ENTRY(nsIProtocolProxyCallback) + NS_INTERFACE_MAP_ENTRY(nsIProxiedChannel) NS_INTERFACE_MAP_END_INHERITING(nsHashPropertyBag) //----------------------------------------------------------------------------- @@ -3847,18 +3848,6 @@ nsHttpChannel::SetCookie(const char *aCookieHeader) this); } -NS_IMETHODIMP -nsHttpChannel::GetProxyInfo(nsIProxyInfo **result) -{ - if (!mConnectionInfo) - *result = nsnull; - else { - *result = mConnectionInfo->ProxyInfo(); - NS_IF_ADDREF(*result); - } - return NS_OK; -} - //----------------------------------------------------------------------------- // nsHttpChannel::nsISupportsPriority //----------------------------------------------------------------------------- @@ -3920,6 +3909,22 @@ nsHttpChannel::OnProxyAvailable(nsICancelable *request, nsIURI *uri, return NS_OK; } +//----------------------------------------------------------------------------- +// nsHttpChannel::nsIProxiedChannel +//----------------------------------------------------------------------------- + +NS_IMETHODIMP +nsHttpChannel::GetProxyInfo(nsIProxyInfo **result) +{ + if (!mConnectionInfo) + *result = nsnull; + else { + *result = mConnectionInfo->ProxyInfo(); + NS_IF_ADDREF(*result); + } + return NS_OK; +} + //----------------------------------------------------------------------------- // nsHttpChannel::nsIRequestObserver //----------------------------------------------------------------------------- diff --git a/netwerk/protocol/http/src/nsHttpChannel.h b/netwerk/protocol/http/src/nsHttpChannel.h index 59bd548ba72..98aab490643 100644 --- a/netwerk/protocol/http/src/nsHttpChannel.h +++ b/netwerk/protocol/http/src/nsHttpChannel.h @@ -79,6 +79,7 @@ #include "nsISupportsPriority.h" #include "nsIProtocolProxyCallback.h" #include "nsICancelable.h" +#include "nsIProxiedChannel.h" class nsHttpResponseHead; class nsAHttpConnection; @@ -101,6 +102,7 @@ class nsHttpChannel : public nsHashPropertyBag , public nsIResumableChannel , public nsISupportsPriority , public nsIProtocolProxyCallback + , public nsIProxiedChannel { public: NS_DECL_ISUPPORTS_INHERITED @@ -118,6 +120,7 @@ public: NS_DECL_NSIRESUMABLECHANNEL NS_DECL_NSISUPPORTSPRIORITY NS_DECL_NSIPROTOCOLPROXYCALLBACK + NS_DECL_NSIPROXIEDCHANNEL nsHttpChannel(); virtual ~nsHttpChannel();