nsIProtocolProxyService.idl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* vim:set ts=4 sw=4 sts=4 et: */
  3. /* This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. interface nsICancelable;
  8. interface nsIProtocolProxyCallback;
  9. interface nsIProtocolProxyFilter;
  10. interface nsIProtocolProxyChannelFilter;
  11. interface nsIProxyInfo;
  12. interface nsIChannel;
  13. interface nsIURI;
  14. /**
  15. * nsIProtocolProxyService provides methods to access information about
  16. * various network proxies.
  17. */
  18. [scriptable, uuid(ef57c8b6-e09d-4cd4-9222-2a5d2402e15d)]
  19. interface nsIProtocolProxyService : nsISupports
  20. {
  21. /** Flag 1 << 0 is unused **/
  22. /**
  23. * When the proxy configuration is manual this flag may be passed to the
  24. * resolve and asyncResolve methods to request to prefer the SOCKS proxy
  25. * to HTTP ones.
  26. */
  27. const unsigned long RESOLVE_PREFER_SOCKS_PROXY = 1 << 1;
  28. /**
  29. * When the proxy configuration is manual this flag may be passed to the
  30. * resolve and asyncResolve methods to request to not analyze the uri's
  31. * scheme specific proxy. When this flag is set the main HTTP proxy is the
  32. * preferred one.
  33. *
  34. * NOTE: if RESOLVE_PREFER_SOCKS_PROXY is set then the SOCKS proxy is
  35. * the preferred one.
  36. *
  37. * NOTE: if RESOLVE_PREFER_HTTPS_PROXY is set then the HTTPS proxy
  38. * is the preferred one.
  39. */
  40. const unsigned long RESOLVE_IGNORE_URI_SCHEME = 1 << 2;
  41. /**
  42. * When the proxy configuration is manual this flag may be passed to the
  43. * resolve and asyncResolve methods to request to prefer the HTTPS proxy
  44. * to the others HTTP ones.
  45. *
  46. * NOTE: RESOLVE_PREFER_SOCKS_PROXY takes precedence over this flag.
  47. *
  48. * NOTE: This flag implies RESOLVE_IGNORE_URI_SCHEME.
  49. */
  50. const unsigned long RESOLVE_PREFER_HTTPS_PROXY =
  51. (1 << 3) | RESOLVE_IGNORE_URI_SCHEME;
  52. /**
  53. * When the proxy configuration is manual this flag may be passed to the
  54. * resolve and asyncResolve methods to that all methods will be tunneled via
  55. * CONNECT through the http proxy.
  56. */
  57. const unsigned long RESOLVE_ALWAYS_TUNNEL = (1 << 4);
  58. /**
  59. * This method returns via callback a nsIProxyInfo instance that identifies
  60. * a proxy to be used for the given channel. Otherwise, this method returns
  61. * null indicating that a direct connection should be used.
  62. *
  63. * @param aChannelOrURI
  64. * The channel for which a proxy is to be found, or, if no channel is
  65. * available, a URI indicating the same. This method will return
  66. * NS_ERROR_NOINTERFACE if this argument isn't either an nsIURI or an
  67. * nsIChannel.
  68. * @param aFlags
  69. * A bit-wise combination of the RESOLVE_ flags defined above. Pass
  70. * 0 to specify the default behavior. Any additional bits that do
  71. * not correspond to a RESOLVE_ flag are reserved for future use.
  72. * @param aCallback
  73. * The object to be notified when the result is available.
  74. *
  75. * @return An object that can be used to cancel the asychronous operation.
  76. * If canceled, the cancelation status (aReason) will be forwarded
  77. * to the callback's onProxyAvailable method via the aStatus param.
  78. *
  79. * NOTE: If this proxy is unavailable, getFailoverForProxy may be called
  80. * to determine the correct secondary proxy to be used.
  81. *
  82. * NOTE: If the protocol handler for the given URI supports
  83. * nsIProxiedProtocolHandler, then the nsIProxyInfo instance returned from
  84. * resolve may be passed to the newProxiedChannel method to create a
  85. * nsIChannel to the given URI that uses the specified proxy.
  86. *
  87. * NOTE: However, if the nsIProxyInfo type is "http", then it means that
  88. * the given URI should be loaded using the HTTP protocol handler, which
  89. * also supports nsIProxiedProtocolHandler.
  90. *
  91. * @see nsIProxiedProtocolHandler::newProxiedChannel
  92. */
  93. nsICancelable asyncResolve(in nsISupports aChannelOrURI, in unsigned long aFlags,
  94. in nsIProtocolProxyCallback aCallback);
  95. /**
  96. * This method may be called to construct a nsIProxyInfo instance from
  97. * the given parameters. This method may be useful in conjunction with
  98. * nsISocketTransportService::createTransport for creating, for example,
  99. * a SOCKS connection.
  100. *
  101. * @param aType
  102. * The proxy type. This is a string value that identifies the proxy
  103. * type. Standard values include:
  104. * "http" - specifies a HTTP proxy
  105. * "https" - specifies HTTP proxying over TLS connection to proxy
  106. * "socks" - specifies a SOCKS version 5 proxy
  107. * "socks4" - specifies a SOCKS version 4 proxy
  108. * "direct" - specifies a direct connection (useful for failover)
  109. * The type name is case-insensitive. Other string values may be
  110. * possible, and new types may be defined by a future version of
  111. * this interface.
  112. * @param aHost
  113. * The proxy hostname or IP address.
  114. * @param aPort
  115. * The proxy port.
  116. * @param aFlags
  117. * Flags associated with this connection. See nsIProxyInfo.idl
  118. * for currently defined flags.
  119. * @param aFailoverTimeout
  120. * Specifies the length of time (in seconds) to ignore this proxy if
  121. * this proxy fails. Pass UINT32_MAX to specify the default
  122. * timeout value, causing nsIProxyInfo::failoverTimeout to be
  123. * assigned the default value.
  124. * @param aFailoverProxy
  125. * Specifies the next proxy to try if this proxy fails. This
  126. * parameter may be null.
  127. */
  128. nsIProxyInfo newProxyInfo(in ACString aType, in AUTF8String aHost,
  129. in long aPort, in unsigned long aFlags,
  130. in unsigned long aFailoverTimeout,
  131. in nsIProxyInfo aFailoverProxy);
  132. /**
  133. * This method may be called to construct a nsIProxyInfo instance for
  134. * with the specified username and password.
  135. * Currently implemented for SOCKS proxies only.
  136. * @param aType
  137. * The proxy type. This is a string value that identifies the proxy
  138. * type. Standard values include:
  139. * "socks" - specifies a SOCKS version 5 proxy
  140. * "socks4" - specifies a SOCKS version 4 proxy
  141. * The type name is case-insensitive. Other string values may be
  142. * possible, and new types may be defined by a future version of
  143. * this interface.
  144. * @param aHost
  145. * The proxy hostname or IP address.
  146. * @param aPort
  147. * The proxy port.
  148. * @param aUsername
  149. * The proxy username
  150. * @param aPassword
  151. * The proxy password
  152. * @param aFlags
  153. * Flags associated with this connection. See nsIProxyInfo.idl
  154. * for currently defined flags.
  155. * @param aFailoverTimeout
  156. * Specifies the length of time (in seconds) to ignore this proxy if
  157. * this proxy fails. Pass UINT32_MAX to specify the default
  158. * timeout value, causing nsIProxyInfo::failoverTimeout to be
  159. * assigned the default value.
  160. * @param aFailoverProxy
  161. * Specifies the next proxy to try if this proxy fails. This
  162. * parameter may be null.
  163. */
  164. nsIProxyInfo newProxyInfoWithAuth(in ACString aType, in AUTF8String aHost,
  165. in long aPort,
  166. in ACString aUsername, in ACString aPassword,
  167. in unsigned long aFlags,
  168. in unsigned long aFailoverTimeout,
  169. in nsIProxyInfo aFailoverProxy);
  170. /**
  171. * If the proxy identified by aProxyInfo is unavailable for some reason,
  172. * this method may be called to access an alternate proxy that may be used
  173. * instead. As a side-effect, this method may affect future result values
  174. * from resolve/asyncResolve as well as from getFailoverForProxy.
  175. *
  176. * @param aProxyInfo
  177. * The proxy that was unavailable.
  178. * @param aURI
  179. * The URI that was originally passed to resolve/asyncResolve.
  180. * @param aReason
  181. * The error code corresponding to the proxy failure. This value
  182. * may be used to tune the delay before this proxy is used again.
  183. *
  184. * @throw NS_ERROR_NOT_AVAILABLE if there is no alternate proxy available.
  185. */
  186. nsIProxyInfo getFailoverForProxy(in nsIProxyInfo aProxyInfo,
  187. in nsIURI aURI,
  188. in nsresult aReason);
  189. /**
  190. * This method may be used to register a proxy filter instance. Each proxy
  191. * filter is registered with an associated position that determines the
  192. * order in which the filters are applied (starting from position 0). When
  193. * resolve/asyncResolve is called, it generates a list of proxies for the
  194. * given URI, and then it applies the proxy filters. The filters have the
  195. * opportunity to modify the list of proxies.
  196. *
  197. * If two filters register for the same position, then the filters will be
  198. * visited in the order in which they were registered.
  199. *
  200. * If the filter is already registered, then its position will be updated.
  201. *
  202. * After filters have been run, any disabled or disallowed proxies will be
  203. * removed from the list. A proxy is disabled if it had previously failed-
  204. * over to another proxy (see getFailoverForProxy). A proxy is disallowed,
  205. * for example, if it is a HTTP proxy and the nsIProtocolHandler for the
  206. * queried URI does not permit proxying via HTTP.
  207. *
  208. * If a nsIProtocolHandler disallows all proxying, then filters will never
  209. * have a chance to intercept proxy requests for such URLs.
  210. *
  211. * @param aFilter
  212. * The nsIProtocolProxyFilter instance to be registered.
  213. * @param aPosition
  214. * The position of the filter.
  215. *
  216. * NOTE: It is possible to construct filters that compete with one another
  217. * in undesirable ways. This API does not attempt to protect against such
  218. * problems. It is recommended that any extensions that choose to call
  219. * this method make their position value configurable at runtime (perhaps
  220. * via the preferences service).
  221. */
  222. void registerFilter(in nsIProtocolProxyFilter aFilter,
  223. in unsigned long aPosition);
  224. /**
  225. * Similar to registerFilter, but accepts an nsIProtocolProxyChannelFilter,
  226. * which selects proxies according to channel rather than URI.
  227. *
  228. * @param aFilter
  229. * The nsIProtocolProxyChannelFilter instance to be registered.
  230. * @param aPosition
  231. * The position of the filter.
  232. */
  233. void registerChannelFilter(in nsIProtocolProxyChannelFilter aFilter,
  234. in unsigned long aPosition);
  235. /**
  236. * This method may be used to unregister a proxy filter instance. All
  237. * filters will be automatically unregistered at XPCOM shutdown.
  238. *
  239. * @param aFilter
  240. * The nsIProtocolProxyFilter instance to be unregistered.
  241. */
  242. void unregisterFilter(in nsIProtocolProxyFilter aFilter);
  243. /**
  244. * This method may be used to unregister a proxy channel filter instance. All
  245. * filters will be automatically unregistered at XPCOM shutdown.
  246. *
  247. * @param aFilter
  248. * The nsIProtocolProxyChannelFilter instance to be unregistered.
  249. */
  250. void unregisterChannelFilter(in nsIProtocolProxyChannelFilter aFilter);
  251. /**
  252. * These values correspond to the possible integer values for the
  253. * network.proxy.type preference.
  254. */
  255. const unsigned long PROXYCONFIG_DIRECT = 0;
  256. const unsigned long PROXYCONFIG_MANUAL = 1;
  257. const unsigned long PROXYCONFIG_PAC = 2;
  258. const unsigned long PROXYCONFIG_WPAD = 4;
  259. const unsigned long PROXYCONFIG_SYSTEM = 5;
  260. /**
  261. * This attribute specifies the current type of proxy configuration.
  262. */
  263. readonly attribute unsigned long proxyConfigType;
  264. };