mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 436344 - Allow filtering of proxies by channel. r=mcmanus
This commit is contained in:
parent
33672c418f
commit
74eea736dc
@ -97,6 +97,7 @@ LOCAL_INCLUDES += [
|
||||
'/dom/plugins/ipc',
|
||||
'/layout/generic',
|
||||
'/layout/xul',
|
||||
'/netwerk/base',
|
||||
'/widget',
|
||||
'/widget/android',
|
||||
'/widget/cocoa',
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIProtocolProxyService2.h"
|
||||
#include "nsProtocolProxyService.h"
|
||||
#include "nsIStreamConverterService.h"
|
||||
#include "nsIFile.h"
|
||||
#if defined(XP_MACOSX)
|
||||
@ -606,32 +606,30 @@ nsresult nsPluginHost::FindProxyForURL(const char* url, char* *result)
|
||||
}
|
||||
nsresult res;
|
||||
|
||||
nsCOMPtr<nsIURI> uriIn;
|
||||
nsCOMPtr<nsIProtocolProxyService> proxyService;
|
||||
nsCOMPtr<nsIProtocolProxyService2> proxyService2;
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
|
||||
proxyService = do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &res);
|
||||
nsCOMPtr<nsIProtocolProxyService> proxyService =
|
||||
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &res);
|
||||
if (NS_FAILED(res) || !proxyService)
|
||||
return res;
|
||||
|
||||
proxyService2 = do_QueryInterface(proxyService, &res);
|
||||
if (NS_FAILED(res) || !proxyService2)
|
||||
return res;
|
||||
nsRefPtr<nsProtocolProxyService> rawProxyService = do_QueryObject(proxyService);
|
||||
if (!rawProxyService) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &res);
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &res);
|
||||
if (NS_FAILED(res) || !ioService)
|
||||
return res;
|
||||
|
||||
// make an nsURI from the argument url
|
||||
res = ioService->NewURI(nsDependentCString(url), nullptr, nullptr, getter_AddRefs(uriIn));
|
||||
// make a temporary channel from the argument url
|
||||
nsCOMPtr<nsIChannel> tempChannel;
|
||||
res = ioService->NewChannel(nsDependentCString(url), nullptr, nullptr, getter_AddRefs(tempChannel));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
nsCOMPtr<nsIProxyInfo> pi;
|
||||
|
||||
// Remove this with bug 778201
|
||||
res = proxyService2->DeprecatedBlockingResolve(uriIn, 0, getter_AddRefs(pi));
|
||||
// Remove this deprecated call in the future (see Bug 778201):
|
||||
res = rawProxyService->DeprecatedBlockingResolve(tempChannel, 0, getter_AddRefs(pi));
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
|
||||
|
@ -1507,7 +1507,7 @@ private:
|
||||
NS_IMPL_ISUPPORTS(IOServiceProxyCallback, nsIProtocolProxyCallback)
|
||||
|
||||
NS_IMETHODIMP
|
||||
IOServiceProxyCallback::OnProxyAvailable(nsICancelable *request, nsIURI *aURI,
|
||||
IOServiceProxyCallback::OnProxyAvailable(nsICancelable *request, nsIChannel *channel,
|
||||
nsIProxyInfo *pi, nsresult status)
|
||||
{
|
||||
// Checking proxy status for speculative connect
|
||||
@ -1519,8 +1519,14 @@ IOServiceProxyCallback::OnProxyAvailable(nsICancelable *request, nsIURI *aURI,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsAutoCString scheme;
|
||||
nsresult rv = aURI->GetScheme(scheme);
|
||||
rv = uri->GetScheme(scheme);
|
||||
if (NS_FAILED(rv))
|
||||
return NS_OK;
|
||||
|
||||
@ -1535,7 +1541,7 @@ IOServiceProxyCallback::OnProxyAvailable(nsICancelable *request, nsIURI *aURI,
|
||||
if (!speculativeHandler)
|
||||
return NS_OK;
|
||||
|
||||
speculativeHandler->SpeculativeConnect(aURI,
|
||||
speculativeHandler->SpeculativeConnect(uri,
|
||||
mCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1553,10 +1559,16 @@ nsIOService::SpeculativeConnect(nsIURI *aURI,
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NewChannelFromURI(aURI, getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICancelable> cancelable;
|
||||
nsRefPtr<IOServiceProxyCallback> callback =
|
||||
new IOServiceProxyCallback(aCallbacks, this);
|
||||
return pps->AsyncResolve(aURI, 0, callback, getter_AddRefs(cancelable));
|
||||
return pps->AsyncResolve(channel, 0, callback, getter_AddRefs(cancelable));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIChannel;
|
||||
interface nsIProxyInfo;
|
||||
interface nsICancelable;
|
||||
|
||||
@ -14,7 +14,7 @@ interface nsICancelable;
|
||||
* This interface serves as a closure for nsIProtocolProxyService's
|
||||
* asyncResolve method.
|
||||
*/
|
||||
[scriptable, uuid(a9967200-f95e-45c2-beb3-9b060d874bfd)]
|
||||
[scriptable, uuid(fbb6eff6-0cc2-4d99-8d6f-0a12b462bdeb)]
|
||||
interface nsIProtocolProxyCallback : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -23,8 +23,8 @@ interface nsIProtocolProxyCallback : nsISupports
|
||||
*
|
||||
* @param aRequest
|
||||
* The value returned from asyncResolve.
|
||||
* @param aURI
|
||||
* The URI passed to asyncResolve.
|
||||
* @param aChannel
|
||||
* The channel passed to asyncResolve.
|
||||
* @param aProxyInfo
|
||||
* The resulting proxy info or null if there is no associated proxy
|
||||
* info for aURI. As with the result of nsIProtocolProxyService's
|
||||
@ -36,7 +36,7 @@ interface nsIProtocolProxyCallback : nsISupports
|
||||
* indicates the reason for the failure and aProxyInfo will be null.
|
||||
*/
|
||||
void onProxyAvailable(in nsICancelable aRequest,
|
||||
in nsIURI aURI,
|
||||
in nsIChannel aChannel,
|
||||
in nsIProxyInfo aProxyInfo,
|
||||
in nsresult aStatus);
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIChannel;
|
||||
interface nsIProtocolProxyService;
|
||||
interface nsIProxyInfo;
|
||||
interface nsIURI;
|
||||
@ -13,7 +14,7 @@ interface nsIURI;
|
||||
/**
|
||||
* This interface is used to apply filters to the proxies selected for a given
|
||||
* URI. Use nsIProtocolProxyService::registerFilter to hook up instances of
|
||||
* this interface.
|
||||
* this interface. See also nsIProtocolProxyChannelFilter.
|
||||
*/
|
||||
[scriptable, uuid(f424abd3-32b4-456c-9f45-b7e3376cb0d1)]
|
||||
interface nsIProtocolProxyFilter : nsISupports
|
||||
@ -40,3 +41,34 @@ interface nsIProtocolProxyFilter : nsISupports
|
||||
nsIProxyInfo applyFilter(in nsIProtocolProxyService aProxyService,
|
||||
in nsIURI aURI, in nsIProxyInfo aProxy);
|
||||
};
|
||||
|
||||
/**
|
||||
* This interface is used to apply filters to the proxies selected for a given
|
||||
* channel. Use nsIProtocolProxyService::registerChannelFilter to hook up instances of
|
||||
* this interface. See also nsIProtocolProxyFilter.
|
||||
*/
|
||||
[scriptable, uuid(245b0880-82c5-4e6e-be6d-bc586aa55a90)]
|
||||
interface nsIProtocolProxyChannelFilter : nsISupports
|
||||
{
|
||||
/**
|
||||
* This method is called to apply proxy filter rules for the given channel
|
||||
* and proxy object (or list of proxy objects).
|
||||
*
|
||||
* @param aProxyService
|
||||
* A reference to the Protocol Proxy Service. This is passed so that
|
||||
* implementations may easily access methods such as newProxyInfo.
|
||||
* @param aChannel
|
||||
* The channel for which these proxy settings apply.
|
||||
* @param aProxy
|
||||
* The proxy (or list of proxies) that would be used by default for
|
||||
* the given channel. This may be null.
|
||||
*
|
||||
* @return The proxy (or list of proxies) that should be used in place of
|
||||
* aProxy. This can be just be aProxy if the filter chooses not to
|
||||
* modify the proxy. It can also be null to indicate that a direct
|
||||
* connection should be used. Use aProxyService.newProxyInfo to
|
||||
* construct nsIProxyInfo objects.
|
||||
*/
|
||||
nsIProxyInfo applyFilter(in nsIProtocolProxyService aProxyService,
|
||||
in nsIChannel aChannel, in nsIProxyInfo aProxy);
|
||||
};
|
||||
|
@ -9,6 +9,7 @@
|
||||
interface nsICancelable;
|
||||
interface nsIProtocolProxyCallback;
|
||||
interface nsIProtocolProxyFilter;
|
||||
interface nsIProtocolProxyChannelFilter;
|
||||
interface nsIProxyInfo;
|
||||
interface nsIChannel;
|
||||
interface nsIURI;
|
||||
@ -17,7 +18,7 @@ interface nsIURI;
|
||||
* nsIProtocolProxyService provides methods to access information about
|
||||
* various network proxies.
|
||||
*/
|
||||
[scriptable, uuid(e77c642b-026f-41ce-9b23-f829a6e3f300)]
|
||||
[scriptable, uuid(ab363090-c331-489f-aabb-7fe4481795b8)]
|
||||
interface nsIProtocolProxyService : nsISupports
|
||||
{
|
||||
/** Flag 1 << 0 is unused **/
|
||||
@ -64,11 +65,11 @@ interface nsIProtocolProxyService : nsISupports
|
||||
|
||||
/**
|
||||
* This method returns via callback a nsIProxyInfo instance that identifies
|
||||
* a proxy to be used for loading the given URI. Otherwise, this method returns
|
||||
* a proxy to be used for the given channel. Otherwise, this method returns
|
||||
* null indicating that a direct connection should be used.
|
||||
*
|
||||
* @param aURI
|
||||
* The URI to test.
|
||||
* @param aChannel
|
||||
* The channel for which a proxy is to be found.
|
||||
* @param aFlags
|
||||
* A bit-wise combination of the RESOLVE_ flags defined above. Pass
|
||||
* 0 to specify the default behavior. Any additional bits that do
|
||||
@ -94,7 +95,7 @@ interface nsIProtocolProxyService : nsISupports
|
||||
*
|
||||
* @see nsIProxiedProtocolHandler::newProxiedChannel
|
||||
*/
|
||||
nsICancelable asyncResolve(in nsIURI aURI, in unsigned long aFlags,
|
||||
nsICancelable asyncResolve(in nsIChannel aChannel, in unsigned long aFlags,
|
||||
in nsIProtocolProxyCallback aCallback);
|
||||
|
||||
/**
|
||||
@ -191,6 +192,18 @@ interface nsIProtocolProxyService : nsISupports
|
||||
void registerFilter(in nsIProtocolProxyFilter aFilter,
|
||||
in unsigned long aPosition);
|
||||
|
||||
/**
|
||||
* Similar to registerFilter, but accepts an nsIProtocolProxyChannelFilter,
|
||||
* which selects proxies according to channel rather than URI.
|
||||
*
|
||||
* @param aFilter
|
||||
* The nsIProtocolProxyChannelFilter instance to be registered.
|
||||
* @param aPosition
|
||||
* The position of the filter.
|
||||
*/
|
||||
void registerChannelFilter(in nsIProtocolProxyChannelFilter aFilter,
|
||||
in unsigned long aPosition);
|
||||
|
||||
/**
|
||||
* This method may be used to unregister a proxy filter instance. All
|
||||
* filters will be automatically unregistered at XPCOM shutdown.
|
||||
@ -200,6 +213,15 @@ interface nsIProtocolProxyService : nsISupports
|
||||
*/
|
||||
void unregisterFilter(in nsIProtocolProxyFilter aFilter);
|
||||
|
||||
/**
|
||||
* This method may be used to unregister a proxy channel filter instance. All
|
||||
* filters will be automatically unregistered at XPCOM shutdown.
|
||||
*
|
||||
* @param aFilter
|
||||
* The nsIProtocolProxyChannelFilter instance to be unregistered.
|
||||
*/
|
||||
void unregisterChannelFilter(in nsIProtocolProxyChannelFilter aFilter);
|
||||
|
||||
/**
|
||||
* These values correspond to the possible integer values for the
|
||||
* network.proxy.type preference.
|
||||
|
@ -9,7 +9,7 @@
|
||||
/**
|
||||
* An extension of nsIProtocolProxyService
|
||||
*/
|
||||
[scriptable, uuid(bb52e571-4a0e-4363-83d0-52034910dd14)]
|
||||
[scriptable, uuid(b2e5b2c0-e21e-4845-b336-be6d60a38951)]
|
||||
interface nsIProtocolProxyService2 : nsIProtocolProxyService
|
||||
{
|
||||
/**
|
||||
@ -18,21 +18,12 @@ interface nsIProtocolProxyService2 : nsIProtocolProxyService
|
||||
*/
|
||||
void reloadPAC();
|
||||
|
||||
/**
|
||||
* This exists so Java(tm) can migrate to an asynchronous interface.
|
||||
* Do not use this unless you are the plugin interface, and even then you
|
||||
* ought to feel horribly guilty because you will create main thread jank.
|
||||
*
|
||||
* No documentation - it is deprecated!
|
||||
**/
|
||||
nsIProxyInfo deprecatedBlockingResolve(in nsIURI aURI, in unsigned long aFlags);
|
||||
|
||||
/**
|
||||
* This method is identical to asyncResolve() except it may execute the
|
||||
* callback function immediately (i.e from the stack of asyncResolve2()) if
|
||||
* it is immediately ready to run. The nsICancelable return value will be
|
||||
* null in that case.
|
||||
*/
|
||||
nsICancelable asyncResolve2(in nsIURI aURI, in unsigned long aFlags,
|
||||
nsICancelable asyncResolve2(in nsIChannel aChannel, in unsigned long aFlags,
|
||||
in nsIProtocolProxyCallback aCallback);
|
||||
};
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIProtocolProxyCallback.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsICancelable.h"
|
||||
#include "nsIDNSService.h"
|
||||
#include "nsPIDNSService.h"
|
||||
@ -30,6 +31,7 @@
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "nsISystemProxySettings.h"
|
||||
#include "nsINetworkLinkService.h"
|
||||
#include "nsIHttpChannelInternal.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
@ -68,6 +70,29 @@ struct nsProtocolInfo {
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// Return the channel's proxy URI, or if it doesn't exist, the
|
||||
// channel's main URI.
|
||||
static nsresult
|
||||
GetProxyURI(nsIChannel *channel, nsIURI **aOut)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> proxyURI;
|
||||
nsCOMPtr<nsIHttpChannelInternal> httpChannel(do_QueryInterface(channel));
|
||||
if (httpChannel) {
|
||||
rv = httpChannel->GetProxyURI(getter_AddRefs(proxyURI));
|
||||
}
|
||||
if (!proxyURI) {
|
||||
rv = channel->GetURI(getter_AddRefs(proxyURI));
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
proxyURI.forget(aOut);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// The nsPACManCallback portion of this implementation should be run
|
||||
// on the main thread - so call nsPACMan::AsyncGetProxyForURI() with
|
||||
// a true mainThreadResponse parameter.
|
||||
@ -78,7 +103,7 @@ class nsAsyncResolveRequest MOZ_FINAL : public nsIRunnable
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
nsAsyncResolveRequest(nsProtocolProxyService *pps, nsIURI *uri,
|
||||
nsAsyncResolveRequest(nsProtocolProxyService *pps, nsIChannel *channel,
|
||||
uint32_t aResolveFlags,
|
||||
nsIProtocolProxyCallback *callback)
|
||||
: mStatus(NS_OK)
|
||||
@ -86,7 +111,7 @@ public:
|
||||
, mResolveFlags(aResolveFlags)
|
||||
, mPPS(pps)
|
||||
, mXPComPPS(pps)
|
||||
, mURI(uri)
|
||||
, mChannel(channel)
|
||||
, mCallback(callback)
|
||||
{
|
||||
NS_ASSERTION(mCallback, "null callback");
|
||||
@ -103,9 +128,9 @@ private:
|
||||
nsCOMPtr<nsIThread> mainThread;
|
||||
NS_GetMainThread(getter_AddRefs(mainThread));
|
||||
|
||||
if (mURI) {
|
||||
nsIURI *forgettable;
|
||||
mURI.forget(&forgettable);
|
||||
if (mChannel) {
|
||||
nsIChannel *forgettable;
|
||||
mChannel.forget(&forgettable);
|
||||
NS_ProxyRelease(mainThread, forgettable, false);
|
||||
}
|
||||
|
||||
@ -211,34 +236,39 @@ private:
|
||||
if (NS_SUCCEEDED(mStatus) && !mProxyInfo && !mPACString.IsEmpty()) {
|
||||
mPPS->ProcessPACString(mPACString, mResolveFlags,
|
||||
getter_AddRefs(mProxyInfo));
|
||||
nsCOMPtr<nsIURI> proxyURI;
|
||||
GetProxyURI(mChannel, getter_AddRefs(proxyURI));
|
||||
|
||||
// Now apply proxy filters
|
||||
nsProtocolInfo info;
|
||||
mStatus = mPPS->GetProtocolInfo(mURI, &info);
|
||||
mStatus = mPPS->GetProtocolInfo(proxyURI, &info);
|
||||
if (NS_SUCCEEDED(mStatus))
|
||||
mPPS->ApplyFilters(mURI, info, mProxyInfo);
|
||||
mPPS->ApplyFilters(mChannel, info, mProxyInfo);
|
||||
else
|
||||
mProxyInfo = nullptr;
|
||||
|
||||
LOG(("pac thread callback %s\n", mPACString.get()));
|
||||
if (NS_SUCCEEDED(mStatus))
|
||||
mPPS->MaybeDisableDNSPrefetch(mProxyInfo);
|
||||
mCallback->OnProxyAvailable(this, mURI, mProxyInfo, mStatus);
|
||||
mCallback->OnProxyAvailable(this, mChannel, mProxyInfo, mStatus);
|
||||
}
|
||||
else if (NS_SUCCEEDED(mStatus) && !mPACURL.IsEmpty()) {
|
||||
LOG(("pac thread callback indicates new pac file load\n"));
|
||||
|
||||
nsCOMPtr<nsIURI> proxyURI;
|
||||
GetProxyURI(mChannel, getter_AddRefs(proxyURI));
|
||||
|
||||
// trigger load of new pac url
|
||||
nsresult rv = mPPS->ConfigureFromPAC(mPACURL, false);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// now that the load is triggered, we can resubmit the query
|
||||
nsRefPtr<nsAsyncResolveRequest> newRequest =
|
||||
new nsAsyncResolveRequest(mPPS, mURI, mResolveFlags, mCallback);
|
||||
rv = mPPS->mPACMan->AsyncGetProxyForURI(mURI, newRequest, true);
|
||||
new nsAsyncResolveRequest(mPPS, mChannel, mResolveFlags, mCallback);
|
||||
rv = mPPS->mPACMan->AsyncGetProxyForURI(proxyURI, newRequest, true);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
mCallback->OnProxyAvailable(this, mURI, nullptr, rv);
|
||||
mCallback->OnProxyAvailable(this, mChannel, nullptr, rv);
|
||||
|
||||
// do not call onproxyavailable() in SUCCESS case - the newRequest will
|
||||
// take care of that
|
||||
@ -247,7 +277,7 @@ private:
|
||||
LOG(("pac thread callback did not provide information %X\n", mStatus));
|
||||
if (NS_SUCCEEDED(mStatus))
|
||||
mPPS->MaybeDisableDNSPrefetch(mProxyInfo);
|
||||
mCallback->OnProxyAvailable(this, mURI, mProxyInfo, mStatus);
|
||||
mCallback->OnProxyAvailable(this, mChannel, mProxyInfo, mStatus);
|
||||
}
|
||||
|
||||
// We are on the main thread now and don't need these any more so
|
||||
@ -256,7 +286,7 @@ private:
|
||||
mCallback = nullptr; // in case the callback holds an owning ref to us
|
||||
mPPS = nullptr;
|
||||
mXPComPPS = nullptr;
|
||||
mURI = nullptr;
|
||||
mChannel = nullptr;
|
||||
mProxyInfo = nullptr;
|
||||
}
|
||||
|
||||
@ -270,7 +300,7 @@ private:
|
||||
|
||||
nsProtocolProxyService *mPPS;
|
||||
nsCOMPtr<nsIProtocolProxyService> mXPComPPS;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsCOMPtr<nsIProtocolProxyCallback> mCallback;
|
||||
nsCOMPtr<nsIProxyInfo> mProxyInfo;
|
||||
};
|
||||
@ -1098,16 +1128,20 @@ private:
|
||||
};
|
||||
NS_IMPL_ISUPPORTS0(nsAsyncBridgeRequest)
|
||||
|
||||
// nsIProtocolProxyService2
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::DeprecatedBlockingResolve(nsIURI *aURI,
|
||||
// nsProtocolProxyService
|
||||
nsresult
|
||||
nsProtocolProxyService::DeprecatedBlockingResolve(nsIChannel *aChannel,
|
||||
uint32_t aFlags,
|
||||
nsIProxyInfo **retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aURI);
|
||||
NS_ENSURE_ARG_POINTER(aChannel);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetProxyURI(aChannel, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsProtocolInfo info;
|
||||
nsresult rv = GetProtocolInfo(aURI, &info);
|
||||
rv = GetProtocolInfo(uri, &info);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -1118,12 +1152,12 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIURI *aURI,
|
||||
// but if neither of them are in use, we can just do the work
|
||||
// right here and directly invoke the callback
|
||||
|
||||
rv = Resolve_Internal(aURI, info, aFlags, &usePACThread, getter_AddRefs(pi));
|
||||
rv = Resolve_Internal(aChannel, info, aFlags, &usePACThread, getter_AddRefs(pi));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!usePACThread || !mPACMan) {
|
||||
ApplyFilters(aURI, info, pi);
|
||||
ApplyFilters(aChannel, info, pi);
|
||||
pi.forget(retval);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1132,7 +1166,7 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIURI *aURI,
|
||||
// code, but block this thread on that completion.
|
||||
nsRefPtr<nsAsyncBridgeRequest> ctx = new nsAsyncBridgeRequest();
|
||||
ctx->Lock();
|
||||
if (NS_SUCCEEDED(mPACMan->AsyncGetProxyForURI(aURI, ctx, false))) {
|
||||
if (NS_SUCCEEDED(mPACMan->AsyncGetProxyForURI(uri, ctx, false))) {
|
||||
// this can really block the main thread, so cap it at 3 seconds
|
||||
ctx->Wait();
|
||||
}
|
||||
@ -1148,7 +1182,7 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIURI *aURI,
|
||||
if (!ctx->mPACString.IsEmpty()) {
|
||||
LOG(("sync pac thread callback %s\n", ctx->mPACString.get()));
|
||||
ProcessPACString(ctx->mPACString, 0, getter_AddRefs(pi));
|
||||
ApplyFilters(aURI, info, pi);
|
||||
ApplyFilters(aChannel, info, pi);
|
||||
pi.forget(retval);
|
||||
return NS_OK;
|
||||
}
|
||||
@ -1172,20 +1206,24 @@ nsProtocolProxyService::DeprecatedBlockingResolve(nsIURI *aURI,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsProtocolProxyService::AsyncResolveInternal(nsIURI *uri, uint32_t flags,
|
||||
nsProtocolProxyService::AsyncResolveInternal(nsIChannel *channel, uint32_t flags,
|
||||
nsIProtocolProxyCallback *callback,
|
||||
nsICancelable **result,
|
||||
bool isSyncOK)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(uri);
|
||||
NS_ENSURE_ARG_POINTER(channel);
|
||||
NS_ENSURE_ARG_POINTER(callback);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = GetProxyURI(channel, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = nullptr;
|
||||
nsRefPtr<nsAsyncResolveRequest> ctx =
|
||||
new nsAsyncResolveRequest(this, uri, flags, callback);
|
||||
new nsAsyncResolveRequest(this, channel, flags, callback);
|
||||
|
||||
nsProtocolInfo info;
|
||||
nsresult rv = GetProtocolInfo(uri, &info);
|
||||
rv = GetProtocolInfo(uri, &info);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -1196,13 +1234,13 @@ nsProtocolProxyService::AsyncResolveInternal(nsIURI *uri, uint32_t flags,
|
||||
// but if neither of them are in use, we can just do the work
|
||||
// right here and directly invoke the callback
|
||||
|
||||
rv = Resolve_Internal(uri, info, flags, &usePACThread, getter_AddRefs(pi));
|
||||
rv = Resolve_Internal(channel, info, flags, &usePACThread, getter_AddRefs(pi));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
if (!usePACThread || !mPACMan) {
|
||||
// we can do it locally
|
||||
ApplyFilters(uri, info, pi);
|
||||
ApplyFilters(channel, info, pi);
|
||||
ctx->SetResult(NS_OK, pi);
|
||||
if (isSyncOK) {
|
||||
ctx->Run();
|
||||
@ -1225,19 +1263,19 @@ nsProtocolProxyService::AsyncResolveInternal(nsIURI *uri, uint32_t flags,
|
||||
|
||||
// nsIProtocolProxyService
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::AsyncResolve2(nsIURI *uri, uint32_t flags,
|
||||
nsProtocolProxyService::AsyncResolve2(nsIChannel *channel, uint32_t flags,
|
||||
nsIProtocolProxyCallback *callback,
|
||||
nsICancelable **result)
|
||||
{
|
||||
return AsyncResolveInternal(uri, flags, callback, result, true);
|
||||
return AsyncResolveInternal(channel, flags, callback, result, true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::AsyncResolve(nsIURI *uri, uint32_t flags,
|
||||
nsProtocolProxyService::AsyncResolve(nsIChannel *channel, uint32_t flags,
|
||||
nsIProtocolProxyCallback *callback,
|
||||
nsICancelable **result)
|
||||
{
|
||||
return AsyncResolveInternal(uri, flags, callback, result, false);
|
||||
return AsyncResolveInternal(channel, flags, callback, result, false);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -1310,16 +1348,9 @@ nsProtocolProxyService::GetFailoverForProxy(nsIProxyInfo *aProxy,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::RegisterFilter(nsIProtocolProxyFilter *filter,
|
||||
uint32_t position)
|
||||
nsresult
|
||||
nsProtocolProxyService::InsertFilterLink(FilterLink *link, uint32_t position)
|
||||
{
|
||||
UnregisterFilter(filter); // remove this filter if we already have it
|
||||
|
||||
FilterLink *link = new FilterLink(position, filter);
|
||||
if (!link)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (!mFilters) {
|
||||
mFilters = link;
|
||||
return NS_OK;
|
||||
@ -1347,15 +1378,39 @@ nsProtocolProxyService::RegisterFilter(nsIProtocolProxyFilter *filter,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::UnregisterFilter(nsIProtocolProxyFilter *filter)
|
||||
nsProtocolProxyService::RegisterFilter(nsIProtocolProxyFilter *filter,
|
||||
uint32_t position)
|
||||
{
|
||||
// QI to nsISupports so we can safely test object identity.
|
||||
nsCOMPtr<nsISupports> givenObject = do_QueryInterface(filter);
|
||||
UnregisterFilter(filter); // remove this filter if we already have it
|
||||
|
||||
FilterLink *link = new FilterLink(position, filter);
|
||||
if (!link) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return InsertFilterLink(link, position);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::RegisterChannelFilter(nsIProtocolProxyChannelFilter *channelFilter,
|
||||
uint32_t position)
|
||||
{
|
||||
UnregisterChannelFilter(channelFilter); // remove this filter if we already have it
|
||||
|
||||
FilterLink *link = new FilterLink(position, channelFilter);
|
||||
if (!link) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return InsertFilterLink(link, position);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsProtocolProxyService::RemoveFilterLink(nsISupports* givenObject)
|
||||
{
|
||||
FilterLink *last = nullptr;
|
||||
for (FilterLink *iter = mFilters; iter; iter = iter->next) {
|
||||
nsCOMPtr<nsISupports> object = do_QueryInterface(iter->filter);
|
||||
if (object == givenObject) {
|
||||
nsCOMPtr<nsISupports> object2 = do_QueryInterface(iter->channelFilter);
|
||||
if (object == givenObject || object2 == givenObject) {
|
||||
if (last)
|
||||
last->next = iter->next;
|
||||
else
|
||||
@ -1371,6 +1426,20 @@ nsProtocolProxyService::UnregisterFilter(nsIProtocolProxyFilter *filter)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::UnregisterFilter(nsIProtocolProxyFilter *filter) {
|
||||
// QI to nsISupports so we can safely test object identity.
|
||||
nsCOMPtr<nsISupports> givenObject = do_QueryInterface(filter);
|
||||
return RemoveFilterLink(givenObject);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::UnregisterChannelFilter(nsIProtocolProxyChannelFilter *channelFilter) {
|
||||
// QI to nsISupports so we can safely test object identity.
|
||||
nsCOMPtr<nsISupports> givenObject = do_QueryInterface(channelFilter);
|
||||
return RemoveFilterLink(givenObject);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsProtocolProxyService::GetProxyConfigType(uint32_t* aProxyConfigType)
|
||||
{
|
||||
@ -1578,13 +1647,13 @@ nsProtocolProxyService::NewProxyInfo_Internal(const char *aType,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsProtocolProxyService::Resolve_Internal(nsIURI *uri,
|
||||
nsProtocolProxyService::Resolve_Internal(nsIChannel *channel,
|
||||
const nsProtocolInfo &info,
|
||||
uint32_t flags,
|
||||
bool *usePACThread,
|
||||
nsIProxyInfo **result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(uri);
|
||||
NS_ENSURE_ARG_POINTER(channel);
|
||||
nsresult rv = SetupPACThread();
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
@ -1595,6 +1664,10 @@ nsProtocolProxyService::Resolve_Internal(nsIURI *uri,
|
||||
if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY))
|
||||
return NS_OK; // Can't proxy this (filters may not override)
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = GetProxyURI(channel, getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// See bug #586908.
|
||||
// Avoid endless loop if |uri| is the current PAC-URI. Returning OK
|
||||
// here means that we will not use a proxy for this connection.
|
||||
@ -1764,7 +1837,8 @@ nsProtocolProxyService::MaybeDisableDNSPrefetch(nsIProxyInfo *aProxy)
|
||||
}
|
||||
|
||||
void
|
||||
nsProtocolProxyService::ApplyFilters(nsIURI *uri, const nsProtocolInfo &info,
|
||||
nsProtocolProxyService::ApplyFilters(nsIChannel *channel,
|
||||
const nsProtocolInfo &info,
|
||||
nsIProxyInfo **list)
|
||||
{
|
||||
if (!(info.flags & nsIProtocolHandler::ALLOWS_PROXY))
|
||||
@ -1779,9 +1853,17 @@ nsProtocolProxyService::ApplyFilters(nsIURI *uri, const nsProtocolInfo &info,
|
||||
|
||||
for (FilterLink *iter = mFilters; iter; iter = iter->next) {
|
||||
PruneProxyInfo(info, list);
|
||||
|
||||
rv = iter->filter->ApplyFilter(this, uri, *list,
|
||||
getter_AddRefs(result));
|
||||
if (iter->filter) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = GetProxyURI(channel, getter_AddRefs(uri));
|
||||
if (uri) {
|
||||
rv = iter->filter->ApplyFilter(this, uri, *list,
|
||||
getter_AddRefs(result));
|
||||
}
|
||||
} else if (iter->channelFilter) {
|
||||
rv = iter->channelFilter->ApplyFilter(this, channel, *list,
|
||||
getter_AddRefs(result));
|
||||
}
|
||||
if (NS_FAILED(rv))
|
||||
continue;
|
||||
result.swap(*list);
|
||||
|
@ -27,6 +27,12 @@ class nsIPrefBranch;
|
||||
class nsISystemProxySettings;
|
||||
class nsPACMan;
|
||||
|
||||
// CID for the nsProtocolProxyService class
|
||||
// 091eedd8-8bae-4fe3-ad62-0c87351e640d
|
||||
#define NS_PROTOCOL_PROXY_SERVICE_IMPL_CID \
|
||||
{ 0x091eedd8, 0x8bae, 0x4fe3, \
|
||||
{ 0xad, 0x62, 0x0c, 0x87, 0x35, 0x1e, 0x64, 0x0d } }
|
||||
|
||||
class nsProtocolProxyService MOZ_FINAL : public nsIProtocolProxyService2
|
||||
, public nsIObserver
|
||||
{
|
||||
@ -36,9 +42,14 @@ public:
|
||||
NS_DECL_NSIPROTOCOLPROXYSERVICE
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PROTOCOL_PROXY_SERVICE_IMPL_CID)
|
||||
|
||||
nsProtocolProxyService();
|
||||
|
||||
nsresult Init();
|
||||
nsresult DeprecatedBlockingResolve(nsIChannel *aChannel,
|
||||
uint32_t aFlags,
|
||||
nsIProxyInfo **retval);
|
||||
|
||||
protected:
|
||||
friend class nsAsyncResolveRequest;
|
||||
@ -192,8 +203,8 @@ protected:
|
||||
* caller with either the proxy info result or a flag to instruct the
|
||||
* caller to use PAC instead.
|
||||
*
|
||||
* @param uri
|
||||
* The URI to test.
|
||||
* @param channel
|
||||
* The channel to test.
|
||||
* @param info
|
||||
* Information about the URI's protocol.
|
||||
* @param flags
|
||||
@ -204,7 +215,7 @@ protected:
|
||||
* @param result
|
||||
* The resulting proxy info or null.
|
||||
*/
|
||||
nsresult Resolve_Internal(nsIURI *uri,
|
||||
nsresult Resolve_Internal(nsIChannel *channel,
|
||||
const nsProtocolInfo &info,
|
||||
uint32_t flags,
|
||||
bool *usePAC,
|
||||
@ -214,26 +225,26 @@ protected:
|
||||
* This method applies the registered filters to the given proxy info
|
||||
* list, and returns a possibly modified list.
|
||||
*
|
||||
* @param uri
|
||||
* The URI corresponding to this proxy info list.
|
||||
* @param channel
|
||||
* The channel corresponding to this proxy info list.
|
||||
* @param info
|
||||
* Information about the URI's protocol.
|
||||
* @param proxyInfo
|
||||
* The proxy info list to be modified. This is an inout param.
|
||||
*/
|
||||
void ApplyFilters(nsIURI *uri, const nsProtocolInfo &info,
|
||||
void ApplyFilters(nsIChannel *channel, const nsProtocolInfo &info,
|
||||
nsIProxyInfo **proxyInfo);
|
||||
|
||||
/**
|
||||
* This method is a simple wrapper around ApplyFilters that takes the
|
||||
* proxy info list inout param as a nsCOMPtr.
|
||||
*/
|
||||
inline void ApplyFilters(nsIURI *uri, const nsProtocolInfo &info,
|
||||
inline void ApplyFilters(nsIChannel *channel, const nsProtocolInfo &info,
|
||||
nsCOMPtr<nsIProxyInfo> &proxyInfo)
|
||||
{
|
||||
nsIProxyInfo *pi = nullptr;
|
||||
proxyInfo.swap(pi);
|
||||
ApplyFilters(uri, info, &pi);
|
||||
ApplyFilters(channel, info, &pi);
|
||||
proxyInfo.swap(pi);
|
||||
}
|
||||
|
||||
@ -318,19 +329,27 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
// This structure is allocated for each registered nsIProtocolProxyFilter.
|
||||
// An instance of this struct is allocated for each registered
|
||||
// nsIProtocolProxyFilter and each nsIProtocolProxyChannelFilter.
|
||||
struct FilterLink {
|
||||
struct FilterLink *next;
|
||||
uint32_t position;
|
||||
nsCOMPtr<nsIProtocolProxyFilter> filter;
|
||||
|
||||
nsCOMPtr<nsIProtocolProxyFilter> filter;
|
||||
nsCOMPtr<nsIProtocolProxyChannelFilter> channelFilter;
|
||||
FilterLink(uint32_t p, nsIProtocolProxyFilter *f)
|
||||
: next(nullptr), position(p), filter(f) {}
|
||||
|
||||
: next(nullptr), position(p), filter(f), channelFilter(nullptr) {}
|
||||
FilterLink(uint32_t p, nsIProtocolProxyChannelFilter *cf)
|
||||
: next(nullptr), position(p), filter(nullptr), channelFilter(cf) {}
|
||||
// Chain deletion to simplify cleaning up the filter links
|
||||
~FilterLink() { if (next) delete next; }
|
||||
};
|
||||
|
||||
private:
|
||||
// Private methods to insert and remove FilterLinks from the FilterLink chain.
|
||||
nsresult InsertFilterLink(FilterLink *link, uint32_t position);
|
||||
nsresult RemoveFilterLink(nsISupports *givenObject);
|
||||
|
||||
protected:
|
||||
// Indicates if local hosts (plain hostnames, no dots) should use the proxy
|
||||
bool mFilterLocalHosts;
|
||||
|
||||
@ -366,11 +385,13 @@ protected:
|
||||
int32_t mFailedProxyTimeout;
|
||||
|
||||
private:
|
||||
nsresult AsyncResolveInternal(nsIURI *uri, uint32_t flags,
|
||||
nsresult AsyncResolveInternal(nsIChannel *channel, uint32_t flags,
|
||||
nsIProtocolProxyCallback *callback,
|
||||
nsICancelable **result,
|
||||
bool isSyncOK);
|
||||
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsProtocolProxyService, NS_PROTOCOL_PROXY_SERVICE_IMPL_CID)
|
||||
|
||||
#endif // !nsProtocolProxyService_h__
|
||||
|
@ -1873,7 +1873,7 @@ nsFtpState::Init(nsFtpChannel *channel)
|
||||
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID);
|
||||
|
||||
if (pps && !mChannel->ProxyInfo()) {
|
||||
pps->AsyncResolve(mChannel->URI(), 0, this,
|
||||
pps->AsyncResolve(mChannel, 0, this,
|
||||
getter_AddRefs(mProxyRequest));
|
||||
}
|
||||
|
||||
@ -2361,7 +2361,7 @@ nsFtpState::CloseWithStatus(nsresult status)
|
||||
}
|
||||
|
||||
static nsresult
|
||||
CreateHTTPProxiedChannel(nsIURI *uri, nsIProxyInfo *pi, nsIChannel **newChannel)
|
||||
CreateHTTPProxiedChannel(nsIChannel *channel, nsIProxyInfo *pi, nsIChannel **newChannel)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ioService = do_GetIOService(&rv);
|
||||
@ -2377,11 +2377,14 @@ CreateHTTPProxiedChannel(nsIURI *uri, nsIProxyInfo *pi, nsIChannel **newChannel)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
|
||||
return pph->NewProxiedChannel(uri, pi, 0, nullptr, newChannel);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpState::OnProxyAvailable(nsICancelable *request, nsIURI *uri,
|
||||
nsFtpState::OnProxyAvailable(nsICancelable *request, nsIChannel *channel,
|
||||
nsIProxyInfo *pi, nsresult status)
|
||||
{
|
||||
mProxyRequest = nullptr;
|
||||
@ -2398,7 +2401,7 @@ nsFtpState::OnProxyAvailable(nsICancelable *request, nsIURI *uri,
|
||||
LOG(("FTP:(%p) Configured to use a HTTP proxy channel\n", this));
|
||||
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
if (NS_SUCCEEDED(CreateHTTPProxiedChannel(uri, pi,
|
||||
if (NS_SUCCEEDED(CreateHTTPProxiedChannel(channel, pi,
|
||||
getter_AddRefs(newChannel))) &&
|
||||
NS_SUCCEEDED(mChannel->Redirect(newChannel,
|
||||
nsIChannelEventSink::REDIRECT_INTERNAL,
|
||||
|
@ -73,6 +73,7 @@ HttpBaseChannel::HttpBaseChannel()
|
||||
, mForceNoIntercept(false)
|
||||
, mSuspendCount(0)
|
||||
, mProxyResolveFlags(0)
|
||||
, mProxyURI(nullptr)
|
||||
, mContentDispositionHint(UINT32_MAX)
|
||||
, mHttpHandler(gHttpHandler)
|
||||
, mReferrerPolicy(REFERRER_POLICY_NO_REFERRER_WHEN_DOWNGRADE)
|
||||
@ -1199,6 +1200,17 @@ HttpBaseChannel::SetReferrerWithPolicy(nsIURI *referrer,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Return the channel's proxy URI, or if it doesn't exist, the
|
||||
// channel's main URI.
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetProxyURI(nsIURI **aOut)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aOut);
|
||||
nsCOMPtr<nsIURI> result(mProxyURI);
|
||||
result.forget(aOut);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::GetRequestHeader(const nsACString& aHeader,
|
||||
nsACString& aValue)
|
||||
|
@ -190,6 +190,7 @@ public:
|
||||
NS_IMETHOD ForceNoIntercept() MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetTopWindowURI(nsIURI **aTopWindowURI) MOZ_OVERRIDE;
|
||||
NS_IMETHOD ContinueBeginConnect() MOZ_OVERRIDE;
|
||||
NS_IMETHOD GetProxyURI(nsIURI **proxyURI);
|
||||
|
||||
inline void CleanRedirectCacheChainIfNecessary()
|
||||
{
|
||||
|
@ -2036,10 +2036,10 @@ nsHttpChannel::ResolveProxy()
|
||||
// then it is ok to use that version.
|
||||
nsCOMPtr<nsIProtocolProxyService2> pps2 = do_QueryInterface(pps);
|
||||
if (pps2) {
|
||||
rv = pps2->AsyncResolve2(mProxyURI ? mProxyURI : mURI, mProxyResolveFlags,
|
||||
rv = pps2->AsyncResolve2(this, mProxyResolveFlags,
|
||||
this, getter_AddRefs(mProxyRequest));
|
||||
} else {
|
||||
rv = pps->AsyncResolve(mProxyURI ? mProxyURI : mURI, mProxyResolveFlags,
|
||||
rv = pps->AsyncResolve(this, mProxyResolveFlags,
|
||||
this, getter_AddRefs(mProxyRequest));
|
||||
}
|
||||
|
||||
@ -5072,7 +5072,7 @@ nsHttpChannel::ClearClassFlags(uint32_t inFlags)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHttpChannel::OnProxyAvailable(nsICancelable *request, nsIURI *uri,
|
||||
nsHttpChannel::OnProxyAvailable(nsICancelable *request, nsIChannel *channel,
|
||||
nsIProxyInfo *pi, nsresult status)
|
||||
{
|
||||
LOG(("nsHttpChannel::OnProxyAvailable [this=%p pi=%p status=%x mStatus=%x]\n",
|
||||
|
@ -25,7 +25,7 @@ interface nsIURI;
|
||||
* The callback interface for nsIHttpChannelInternal::HTTPUpgrade()
|
||||
*/
|
||||
|
||||
[scriptable, uuid(4b967b6d-cd1c-49ae-a457-23ff76f5a2e8)]
|
||||
[scriptable, uuid(7b48d081-1dc1-4d08-b7a5-81491bf28c0e)]
|
||||
interface nsIHttpUpgradeListener : nsISupports
|
||||
{
|
||||
void onTransportAvailable(in nsISocketTransport aTransport,
|
||||
@ -230,4 +230,10 @@ interface nsIHttpChannelInternal : nsISupports
|
||||
* channel after a remote classification verdict.
|
||||
*/
|
||||
void continueBeginConnect();
|
||||
|
||||
/**
|
||||
* Read the proxy URI, which, if non-null, will be used to resolve
|
||||
* proxies for this channel.
|
||||
*/
|
||||
readonly attribute nsIURI proxyURI;
|
||||
};
|
||||
|
@ -2562,7 +2562,7 @@ WebSocketChannel::ApplyForAdmission()
|
||||
|
||||
MOZ_ASSERT(!mCancelable);
|
||||
|
||||
return pps->AsyncResolve(mURI,
|
||||
return pps->AsyncResolve(mHttpChannel,
|
||||
nsIProtocolProxyService::RESOLVE_PREFER_HTTPS_PROXY |
|
||||
nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL,
|
||||
this, getter_AddRefs(mCancelable));
|
||||
@ -2683,7 +2683,7 @@ WebSocketChannel::OnLookupComplete(nsICancelable *aRequest,
|
||||
|
||||
// nsIProtocolProxyCallback
|
||||
NS_IMETHODIMP
|
||||
WebSocketChannel::OnProxyAvailable(nsICancelable *aRequest, nsIURI *aURI,
|
||||
WebSocketChannel::OnProxyAvailable(nsICancelable *aRequest, nsIChannel *aChannel,
|
||||
nsIProxyInfo *pi, nsresult status)
|
||||
{
|
||||
if (mStopped) {
|
||||
|
@ -137,6 +137,20 @@ BasicFilter.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
function BasicChannelFilter() {}
|
||||
BasicChannelFilter.prototype = {
|
||||
QueryInterface: function(iid) {
|
||||
if (iid.equals(Components.interfaces.nsIProtocolProxyChannelFilter) ||
|
||||
iid.equals(Components.interfaces.nsISupports))
|
||||
return this;
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
},
|
||||
applyFilter: function(pps, channel, pi) {
|
||||
return pps.newProxyInfo("http", channel.URI.host, 7777, 0, 10,
|
||||
pps.newProxyInfo("direct", "", -1, 0, 0, null));
|
||||
}
|
||||
};
|
||||
|
||||
function resolveCallback() { }
|
||||
resolveCallback.prototype = {
|
||||
nextFunction: null,
|
||||
@ -155,12 +169,12 @@ resolveCallback.prototype = {
|
||||
};
|
||||
|
||||
function run_filter_test() {
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Verify initial state
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test0_1;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
var filter01;
|
||||
@ -178,8 +192,8 @@ function filter_test0_1(pi) {
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test0_2;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test0_2(pi)
|
||||
@ -191,8 +205,8 @@ function filter_test0_2(pi)
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test0_3;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test0_3(pi)
|
||||
@ -206,13 +220,28 @@ function filter_test0_3(pi)
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test0_4;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
var filter03;
|
||||
|
||||
function filter_test0_4(pi)
|
||||
{
|
||||
do_check_eq(pi, null);
|
||||
filter03 = new BasicChannelFilter();
|
||||
pps.registerChannelFilter(filter03, 10);
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test0_5;
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test0_5(pi)
|
||||
{
|
||||
pps.unregisterChannelFilter(filter03);
|
||||
check_proxy(pi, "http", "www.mozilla.org", 7777, 0, 10, true);
|
||||
check_proxy(pi.failoverProxy, "direct", "", -1, 0, 0, false);
|
||||
run_filter_test2();
|
||||
}
|
||||
|
||||
@ -229,8 +258,8 @@ function run_filter_test2() {
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test1_1;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test1_1(pi) {
|
||||
@ -241,8 +270,8 @@ function filter_test1_1(pi) {
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test1_2;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test1_2(pi) {
|
||||
@ -254,8 +283,8 @@ function filter_test1_2(pi) {
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test1_3;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test1_3(pi) {
|
||||
@ -266,7 +295,7 @@ function filter_test1_3(pi) {
|
||||
var filter_3_1;
|
||||
|
||||
function run_filter_test3() {
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Push a filter and verify the results asynchronously
|
||||
|
||||
@ -275,7 +304,7 @@ function run_filter_test3() {
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = filter_test3_1;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function filter_test3_1(pi) {
|
||||
@ -285,7 +314,7 @@ function filter_test3_1(pi) {
|
||||
}
|
||||
|
||||
function run_pref_test() {
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Verify 'direct' setting
|
||||
|
||||
@ -293,7 +322,7 @@ function run_pref_test() {
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = pref_test1_1;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function pref_test1_1(pi)
|
||||
@ -305,8 +334,8 @@ function pref_test1_1(pi)
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = pref_test1_2;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function pref_test1_2(pi)
|
||||
@ -320,8 +349,8 @@ function pref_test1_2(pi)
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = pref_test1_3;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function pref_test1_3(pi)
|
||||
@ -337,8 +366,8 @@ function pref_test1_3(pi)
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = pref_test1_4;
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function pref_test1_4(pi)
|
||||
@ -347,14 +376,6 @@ function pref_test1_4(pi)
|
||||
run_pac_test();
|
||||
}
|
||||
|
||||
function run_protocol_handler_test() {
|
||||
var uri = ios.newURI("moz-test:foopy", null, null);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = protocol_handler_test_1;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
}
|
||||
|
||||
function protocol_handler_test_1(pi)
|
||||
{
|
||||
do_check_eq(pi, null);
|
||||
@ -403,13 +424,13 @@ function run_pac_test() {
|
||||
'function FindProxyForURL(url, host) {' +
|
||||
' return "PROXY foopy:8080; DIRECT";' +
|
||||
'}';
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Configure PAC
|
||||
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
var req = pps.asyncResolve(uri, 0, new TestResolveCallback("http", run_pac2_test));
|
||||
var req = pps.asyncResolve(channel, 0, new TestResolveCallback("http", run_pac2_test));
|
||||
}
|
||||
|
||||
function run_pac2_test() {
|
||||
@ -417,7 +438,7 @@ function run_pac2_test() {
|
||||
'function FindProxyForURL(url, host) {' +
|
||||
' return "HTTPS foopy:8080; DIRECT";' +
|
||||
'}';
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Configure PAC
|
||||
originalTLSProxy = prefs.getBoolPref("network.proxy.proxy_over_tls");
|
||||
@ -425,7 +446,7 @@ function run_pac2_test() {
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
prefs.setBoolPref("network.proxy.proxy_over_tls", true);
|
||||
|
||||
var req = pps.asyncResolve(uri, 0, new TestResolveCallback("https", run_pac3_test));
|
||||
var req = pps.asyncResolve(channel, 0, new TestResolveCallback("https", run_pac3_test));
|
||||
}
|
||||
|
||||
function run_pac3_test() {
|
||||
@ -433,18 +454,18 @@ function run_pac3_test() {
|
||||
'function FindProxyForURL(url, host) {' +
|
||||
' return "HTTPS foopy:8080; DIRECT";' +
|
||||
'}';
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Configure PAC
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
prefs.setBoolPref("network.proxy.proxy_over_tls", false);
|
||||
|
||||
var req = pps.asyncResolve(uri, 0, new TestResolveCallback(null, finish_pac_test));
|
||||
var req = pps.asyncResolve(channel, 0, new TestResolveCallback(null, finish_pac_test));
|
||||
}
|
||||
|
||||
function finish_pac_test() {
|
||||
prefs.setBoolPref("network.proxy.proxy_over_tls", originalTLSProxy);
|
||||
run_protocol_handler_test();
|
||||
run_pac_cancel_test();
|
||||
}
|
||||
|
||||
function TestResolveCancelationCallback() {
|
||||
@ -475,7 +496,7 @@ TestResolveCancelationCallback.prototype = {
|
||||
};
|
||||
|
||||
function run_pac_cancel_test() {
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
// Configure PAC
|
||||
var pac = 'data:text/plain,' +
|
||||
@ -485,7 +506,7 @@ function run_pac_cancel_test() {
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
|
||||
var req = pps.asyncResolve(uri, 0, new TestResolveCancelationCallback());
|
||||
var req = pps.asyncResolve(channel, 0, new TestResolveCancelationCallback());
|
||||
req.cancel(Components.results.NS_ERROR_ABORT);
|
||||
}
|
||||
|
||||
@ -516,11 +537,11 @@ function check_host_filters_cb()
|
||||
function check_host_filter(i) {
|
||||
var uri;
|
||||
dump("*** uri=" + hostList[i] + " bShouldBeFiltered=" + bShouldBeFiltered + "\n");
|
||||
uri = ios.newURI(hostList[i], null, null);
|
||||
var channel = ios.newChannel(hostList[i], null, null);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = host_filter_cb;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function host_filter_cb(proxy)
|
||||
@ -620,14 +641,14 @@ function run_myipaddress_test()
|
||||
|
||||
// no traffic to this IP is ever sent, it is just a public IP that
|
||||
// does not require DNS to determine a route.
|
||||
var uri = ios.newURI("http://192.0.43.10/", null, null);
|
||||
var channel = ios.newChannel("http://192.0.43.10/", null, null);
|
||||
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = myipaddress_callback;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function myipaddress_callback(pi)
|
||||
@ -656,13 +677,13 @@ function run_myipaddress_test_2()
|
||||
' return "PROXY " + myaddr + ":5678";' +
|
||||
'}';
|
||||
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = myipaddress2_callback;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function myipaddress2_callback(pi)
|
||||
@ -685,14 +706,14 @@ function run_failed_script_test()
|
||||
var pac = 'data:text/plain,' +
|
||||
'\nfor(;\n';
|
||||
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = failed_script_callback;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
var directFilter;
|
||||
@ -765,14 +786,14 @@ function run_isresolvable_test()
|
||||
' return "PROXY 127.0.0.1:1234";' +
|
||||
'}';
|
||||
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
var channel = ios.newChannel("http://www.mozilla.org/", null, null);
|
||||
|
||||
prefs.setIntPref("network.proxy.type", 2);
|
||||
prefs.setCharPref("network.proxy.autoconfig_url", pac);
|
||||
|
||||
var cb = new resolveCallback();
|
||||
cb.nextFunction = isresolvable_callback;
|
||||
var req = pps.asyncResolve(uri, 0, cb);
|
||||
var req = pps.asyncResolve(channel, 0, cb);
|
||||
}
|
||||
|
||||
function isresolvable_callback(pi)
|
||||
@ -786,43 +807,9 @@ function isresolvable_callback(pi)
|
||||
do_test_finished();
|
||||
}
|
||||
|
||||
function run_deprecated_sync_test()
|
||||
{
|
||||
var uri = ios.newURI("http://www.mozilla.org/", null, null);
|
||||
|
||||
pps.QueryInterface(Components.interfaces.nsIProtocolProxyService2);
|
||||
|
||||
// Verify initial state
|
||||
var pi = pps.deprecatedBlockingResolve(uri, 0);
|
||||
do_check_eq(pi, null);
|
||||
|
||||
// Push a filter and verify the results
|
||||
var filter1 = new BasicFilter();
|
||||
var filter2 = new BasicFilter();
|
||||
pps.registerFilter(filter1, 10);
|
||||
pps.registerFilter(filter2, 20);
|
||||
|
||||
pi = pps.deprecatedBlockingResolve(uri, 0);
|
||||
check_proxy(pi, "http", "localhost", 8080, 0, 10, true);
|
||||
check_proxy(pi.failoverProxy, "direct", "", -1, 0, 0, false);
|
||||
|
||||
pps.unregisterFilter(filter2);
|
||||
pi = pps.deprecatedBlockingResolve(uri, 0);
|
||||
check_proxy(pi, "http", "localhost", 8080, 0, 10, true);
|
||||
check_proxy(pi.failoverProxy, "direct", "", -1, 0, 0, false);
|
||||
|
||||
// Remove filter and verify that we return to the initial state
|
||||
pps.unregisterFilter(filter1);
|
||||
pi = pps.deprecatedBlockingResolve(uri, 0);
|
||||
do_check_eq(pi, null);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
register_test_protocol_handler();
|
||||
|
||||
// any synchronous tests
|
||||
run_deprecated_sync_test();
|
||||
|
||||
// start of asynchronous test chain
|
||||
run_filter_test();
|
||||
do_test_pending();
|
||||
|
@ -35,8 +35,8 @@
|
||||
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
|
||||
var pps = Cc["@mozilla.org/network/protocol-proxy-service;1"].getService();
|
||||
|
||||
var uri = ios.newURI("http://example.com", null, null);
|
||||
pps.asyncResolve(uri, 0, resolveCallback);
|
||||
var channel = ios.newChannel("http://example.com", null, null);
|
||||
pps.asyncResolve(channel, 0, resolveCallback);
|
||||
}
|
||||
|
||||
function init2(proxyHost, proxyPort) {
|
||||
|
@ -171,8 +171,8 @@ function startup() {
|
||||
|
||||
var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"].getService();
|
||||
|
||||
var uri = ios.newURI("http://example.com", null, null);
|
||||
pps.asyncResolve(uri, 0, resolveCallback);
|
||||
var channel = ios.newChannel("http://example.com", null, null);
|
||||
pps.asyncResolve(channel, 0, resolveCallback);
|
||||
}
|
||||
|
||||
function addNotificationCallback(cb) {
|
||||
|
@ -146,8 +146,8 @@
|
||||
var pps = SpecialPowers.Cc["@mozilla.org/network/protocol-proxy-service;1"]
|
||||
.getService();
|
||||
|
||||
var uri = ios.newURI("http://example.com", null, null);
|
||||
pps.asyncResolve(uri, 0, resolveCallback);
|
||||
var channel = ios.newChannel("http://example.com", null, null);
|
||||
pps.asyncResolve(channel, 0, resolveCallback);
|
||||
}
|
||||
|
||||
// --------------- Test loop spin ----------------
|
||||
|
Loading…
Reference in New Issue
Block a user