bug 346151 Add nsIProxiedChannel to allow querying the proxy info a channel

was created with
r=darin sr=bz
This commit is contained in:
cbiesinger%web.de 2006-08-01 21:28:31 +00:00
Родитель 9d45afbb2b
Коммит 0154617925
14 изменённых файлов: 156 добавлений и 30 удалений

Просмотреть файл

@ -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<nsIHttpChannelInternal> httpInternal =
nsCOMPtr<nsIProxiedChannel> proxied =
do_QueryInterface(httpChannel);
NS_ENSURE_STATE(httpInternal);
NS_ENSURE_STATE(proxied);
nsCOMPtr<nsIProxyInfo> proxyInfo;
httpInternal->GetProxyInfo(getter_AddRefs(proxyInfo));
proxied->GetProxyInfo(getter_AddRefs(proxyInfo));
NS_ENSURE_STATE(proxyInfo);
proxyInfo->GetHost(service);

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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();

Просмотреть файл

@ -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

Просмотреть файл

@ -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();

Просмотреть файл

@ -118,6 +118,7 @@ XPIDLSRCS = \
nsPISocketTransportService.idl \
nsIChannelEventSink.idl \
nsINetUtil.idl \
nsIProxiedChannel.idl \
$(NULL)
EXPORTS = \

Просмотреть файл

@ -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 <cbiesinger@web.de>
*
* 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;
};

Просмотреть файл

@ -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

Просмотреть файл

@ -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)

Просмотреть файл

@ -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)
{

Просмотреть файл

@ -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:

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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
//-----------------------------------------------------------------------------

Просмотреть файл

@ -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();