netwerk/base/public/nsIProtocolProxyService.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/public/nsIProtocolProxyService.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,267 @@
     1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* vim:set ts=4 sw=4 sts=4 et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#include "nsISupports.idl"
    1.11 +
    1.12 +interface nsICancelable;
    1.13 +interface nsIProtocolProxyCallback;
    1.14 +interface nsIProtocolProxyFilter;
    1.15 +interface nsIProtocolProxyChannelFilter;
    1.16 +interface nsIProxyInfo;
    1.17 +interface nsIChannel;
    1.18 +interface nsIURI;
    1.19 +
    1.20 +/**
    1.21 + * nsIProtocolProxyService provides methods to access information about
    1.22 + * various network proxies.
    1.23 + */
    1.24 +[scriptable, uuid(ab363090-c331-489f-aabb-7fe4481795b8)]
    1.25 +interface nsIProtocolProxyService : nsISupports
    1.26 +{
    1.27 +    /** Flag 1 << 0 is unused **/
    1.28 +
    1.29 +    /**
    1.30 +     * When the proxy configuration is manual this flag may be passed to the
    1.31 +     * resolve and asyncResolve methods to request to prefer the SOCKS proxy
    1.32 +     * to HTTP ones.
    1.33 +     */
    1.34 +    const unsigned long RESOLVE_PREFER_SOCKS_PROXY = 1 << 1;
    1.35 +
    1.36 +    /**
    1.37 +     * When the proxy configuration is manual this flag may be passed to the
    1.38 +     * resolve and asyncResolve methods to request to not analyze the uri's
    1.39 +     * scheme specific proxy. When this flag is set the main HTTP proxy is the
    1.40 +     * preferred one.
    1.41 +     *
    1.42 +     * NOTE: if RESOLVE_PREFER_SOCKS_PROXY is set then the SOCKS proxy is
    1.43 +     *       the preferred one.
    1.44 +     *
    1.45 +     * NOTE: if RESOLVE_PREFER_HTTPS_PROXY is set then the HTTPS proxy
    1.46 +     *       is the preferred one.
    1.47 +     */
    1.48 +    const unsigned long RESOLVE_IGNORE_URI_SCHEME = 1 << 2;
    1.49 +
    1.50 +    /**
    1.51 +     * When the proxy configuration is manual this flag may be passed to the
    1.52 +     * resolve and asyncResolve methods to request to prefer the HTTPS proxy
    1.53 +     * to the others HTTP ones.
    1.54 +     *
    1.55 +     * NOTE: RESOLVE_PREFER_SOCKS_PROXY takes precedence over this flag.
    1.56 +     *
    1.57 +     * NOTE: This flag implies RESOLVE_IGNORE_URI_SCHEME.
    1.58 +     */
    1.59 +    const unsigned long RESOLVE_PREFER_HTTPS_PROXY =
    1.60 +        (1 << 3) | RESOLVE_IGNORE_URI_SCHEME;
    1.61 +
    1.62 +    /**
    1.63 +     * When the proxy configuration is manual this flag may be passed to the
    1.64 +     * resolve and asyncResolve methods to that all methods will be tunneled via
    1.65 +     * CONNECT through the http proxy.
    1.66 +     */
    1.67 +    const unsigned long RESOLVE_ALWAYS_TUNNEL = (1 << 4);
    1.68 +
    1.69 +    /**
    1.70 +     * This method returns via callback a nsIProxyInfo instance that identifies
    1.71 +     * a proxy to be used for the given channel.  Otherwise, this method returns
    1.72 +     * null indicating that a direct connection should be used.
    1.73 +     *
    1.74 +     * @param aChannel
    1.75 +     *        The channel for which a proxy is to be found.
    1.76 +     * @param aFlags
    1.77 +     *        A bit-wise combination of the RESOLVE_ flags defined above.  Pass
    1.78 +     *        0 to specify the default behavior.  Any additional bits that do
    1.79 +     *        not correspond to a RESOLVE_ flag are reserved for future use.
    1.80 +     * @param aCallback
    1.81 +     *        The object to be notified when the result is available.
    1.82 +     *
    1.83 +     * @return An object that can be used to cancel the asychronous operation.
    1.84 +     *         If canceled, the cancelation status (aReason) will be forwarded
    1.85 +     *         to the callback's onProxyAvailable method via the aStatus param.
    1.86 +     *
    1.87 +     * NOTE: If this proxy is unavailable, getFailoverForProxy may be called
    1.88 +     * to determine the correct secondary proxy to be used.
    1.89 +     *
    1.90 +     * NOTE: If the protocol handler for the given URI supports
    1.91 +     * nsIProxiedProtocolHandler, then the nsIProxyInfo instance returned from
    1.92 +     * resolve may be passed to the newProxiedChannel method to create a
    1.93 +     * nsIChannel to the given URI that uses the specified proxy.
    1.94 +     *
    1.95 +     * NOTE: However, if the nsIProxyInfo type is "http", then it means that
    1.96 +     * the given URI should be loaded using the HTTP protocol handler, which
    1.97 +     * also supports nsIProxiedProtocolHandler.
    1.98 +     *
    1.99 +     * @see nsIProxiedProtocolHandler::newProxiedChannel 
   1.100 +     */
   1.101 +    nsICancelable asyncResolve(in nsIChannel aChannel, in unsigned long aFlags,
   1.102 +                               in nsIProtocolProxyCallback aCallback);
   1.103 +
   1.104 +    /**
   1.105 +     * This method may be called to construct a nsIProxyInfo instance from
   1.106 +     * the given parameters.  This method may be useful in conjunction with
   1.107 +     * nsISocketTransportService::createTransport for creating, for example,
   1.108 +     * a SOCKS connection.
   1.109 +     *
   1.110 +     * @param aType
   1.111 +     *        The proxy type.  This is a string value that identifies the proxy
   1.112 +     *        type.  Standard values include:
   1.113 +     *          "http"    - specifies a HTTP proxy
   1.114 +     *          "socks"   - specifies a SOCKS version 5 proxy
   1.115 +     *          "socks4"  - specifies a SOCKS version 4 proxy
   1.116 +     *          "direct"  - specifies a direct connection (useful for failover)
   1.117 +     *        The type name is case-insensitive.  Other string values may be
   1.118 +     *        possible, and new types may be defined by a future version of
   1.119 +     *        this interface.
   1.120 +     * @param aHost
   1.121 +     *        The proxy hostname or IP address.
   1.122 +     * @param aPort
   1.123 +     *        The proxy port.
   1.124 +     * @param aFlags
   1.125 +     *        Flags associated with this connection.  See nsIProxyInfo.idl
   1.126 +     *        for currently defined flags.
   1.127 +     * @param aFailoverTimeout
   1.128 +     *        Specifies the length of time (in seconds) to ignore this proxy if
   1.129 +     *        this proxy fails.  Pass UINT32_MAX to specify the default
   1.130 +     *        timeout value, causing nsIProxyInfo::failoverTimeout to be
   1.131 +     *        assigned the default value.
   1.132 +     * @param aFailoverProxy
   1.133 +     *        Specifies the next proxy to try if this proxy fails.  This
   1.134 +     *        parameter may be null.
   1.135 +     */
   1.136 +    nsIProxyInfo newProxyInfo(in ACString aType, in AUTF8String aHost,
   1.137 +                              in long aPort, in unsigned long aFlags,
   1.138 +                              in unsigned long aFailoverTimeout,
   1.139 +                              in nsIProxyInfo aFailoverProxy);
   1.140 +
   1.141 +    /**
   1.142 +     * This method may be called to construct a nsIProxyInfo instance for
   1.143 +     * a SOCKS connection, with the specified username and password.
   1.144 +     * @param aHost
   1.145 +     *        The proxy hostname or IP address.
   1.146 +     * @param aPort
   1.147 +     *        The proxy port.
   1.148 +     * @param aUsername
   1.149 +     *        The SOCKS5 username
   1.150 +     * @param aPassword
   1.151 +     *        The SOCKS5 password
   1.152 +     * @param aFlags
   1.153 +     *        Flags associated with this connection.  See nsIProxyInfo.idl
   1.154 +     *        for currently defined flags.
   1.155 +     * @param aFailoverTimeout
   1.156 +     *        Specifies the length of time (in seconds) to ignore this proxy if
   1.157 +     *        this proxy fails.  Pass UINT32_MAX to specify the default
   1.158 +     *        timeout value, causing nsIProxyInfo::failoverTimeout to be
   1.159 +     *        assigned the default value.
   1.160 +     * @param aFailoverProxy
   1.161 +     *        Specifies the next proxy to try if this proxy fails.  This
   1.162 +     *        parameter may be null.
   1.163 +     */
   1.164 +    nsIProxyInfo newSOCKSProxyInfo(in AUTF8String aHost, in long aPort,
   1.165 +                                   in ACString aUsername, in ACString aPassword,
   1.166 +                                   in unsigned long aFlags,
   1.167 +                                   in unsigned long aFailoverTimeout,
   1.168 +                                   in nsIProxyInfo aFailoverProxy);
   1.169 +
   1.170 +    /**
   1.171 +     * If the proxy identified by aProxyInfo is unavailable for some reason,
   1.172 +     * this method may be called to access an alternate proxy that may be used
   1.173 +     * instead.  As a side-effect, this method may affect future result values
   1.174 +     * from resolve/asyncResolve as well as from getFailoverForProxy.
   1.175 +     *
   1.176 +     * @param aProxyInfo
   1.177 +     *        The proxy that was unavailable.
   1.178 +     * @param aURI
   1.179 +     *        The URI that was originally passed to resolve/asyncResolve.
   1.180 +     * @param aReason
   1.181 +     *        The error code corresponding to the proxy failure.  This value
   1.182 +     *        may be used to tune the delay before this proxy is used again.
   1.183 +     *
   1.184 +     * @throw NS_ERROR_NOT_AVAILABLE if there is no alternate proxy available.
   1.185 +     */
   1.186 +    nsIProxyInfo getFailoverForProxy(in nsIProxyInfo aProxyInfo,
   1.187 +                                     in nsIURI       aURI,
   1.188 +                                     in nsresult     aReason);
   1.189 +
   1.190 +    /**
   1.191 +     * This method may be used to register a proxy filter instance.  Each proxy
   1.192 +     * filter is registered with an associated position that determines the
   1.193 +     * order in which the filters are applied (starting from position 0).  When
   1.194 +     * resolve/asyncResolve is called, it generates a list of proxies for the
   1.195 +     * given URI, and then it applies the proxy filters.  The filters have the
   1.196 +     * opportunity to modify the list of proxies.
   1.197 +     *
   1.198 +     * If two filters register for the same position, then the filters will be
   1.199 +     * visited in the order in which they were registered.
   1.200 +     *
   1.201 +     * If the filter is already registered, then its position will be updated.
   1.202 +     *
   1.203 +     * After filters have been run, any disabled or disallowed proxies will be
   1.204 +     * removed from the list.  A proxy is disabled if it had previously failed-
   1.205 +     * over to another proxy (see getFailoverForProxy).  A proxy is disallowed,
   1.206 +     * for example, if it is a HTTP proxy and the nsIProtocolHandler for the
   1.207 +     * queried URI does not permit proxying via HTTP.
   1.208 +     *
   1.209 +     * If a nsIProtocolHandler disallows all proxying, then filters will never
   1.210 +     * have a chance to intercept proxy requests for such URLs.
   1.211 +     *
   1.212 +     * @param aFilter
   1.213 +     *        The nsIProtocolProxyFilter instance to be registered.
   1.214 +     * @param aPosition
   1.215 +     *        The position of the filter.
   1.216 +     *
   1.217 +     * NOTE: It is possible to construct filters that compete with one another
   1.218 +     * in undesirable ways.  This API does not attempt to protect against such
   1.219 +     * problems.  It is recommended that any extensions that choose to call
   1.220 +     * this method make their position value configurable at runtime (perhaps
   1.221 +     * via the preferences service).
   1.222 +     */
   1.223 +    void registerFilter(in nsIProtocolProxyFilter aFilter,
   1.224 +                        in unsigned long aPosition);
   1.225 +
   1.226 +    /**
   1.227 +     * Similar to registerFilter, but accepts an nsIProtocolProxyChannelFilter,
   1.228 +     * which selects proxies according to channel rather than URI.
   1.229 +     *
   1.230 +     * @param aFilter
   1.231 +     *        The nsIProtocolProxyChannelFilter instance to be registered.
   1.232 +     * @param aPosition
   1.233 +     *        The position of the filter.
   1.234 +     */
   1.235 +    void registerChannelFilter(in nsIProtocolProxyChannelFilter aFilter,
   1.236 +                               in unsigned long aPosition);
   1.237 +
   1.238 +    /**
   1.239 +     * This method may be used to unregister a proxy filter instance.  All
   1.240 +     * filters will be automatically unregistered at XPCOM shutdown.
   1.241 +     *
   1.242 +     * @param aFilter
   1.243 +     *        The nsIProtocolProxyFilter instance to be unregistered.
   1.244 +     */
   1.245 +    void unregisterFilter(in nsIProtocolProxyFilter aFilter);
   1.246 +
   1.247 +    /**
   1.248 +     * This method may be used to unregister a proxy channel filter instance.  All
   1.249 +     * filters will be automatically unregistered at XPCOM shutdown.
   1.250 +     *
   1.251 +     * @param aFilter
   1.252 +     *        The nsIProtocolProxyChannelFilter instance to be unregistered.
   1.253 +     */
   1.254 +    void unregisterChannelFilter(in nsIProtocolProxyChannelFilter aFilter);
   1.255 +
   1.256 +     /**
   1.257 +      * These values correspond to the possible integer values for the
   1.258 +      * network.proxy.type preference.
   1.259 +      */ 
   1.260 +     const unsigned long PROXYCONFIG_DIRECT   = 0;
   1.261 +     const unsigned long PROXYCONFIG_MANUAL   = 1;
   1.262 +     const unsigned long PROXYCONFIG_PAC      = 2;
   1.263 +     const unsigned long PROXYCONFIG_WPAD     = 4;
   1.264 +     const unsigned long PROXYCONFIG_SYSTEM   = 5;
   1.265 +
   1.266 +     /**
   1.267 +      * This attribute specifies the current type of proxy configuration.
   1.268 +      */
   1.269 +     readonly attribute unsigned long proxyConfigType;
   1.270 +};

mercurial