Class ProxyUtils

java.lang.Object
com.ning.http.util.ProxyUtils

public final class ProxyUtils extends Object
Utilities for Proxy handling.
Author:
cstamas
  • Field Details

  • Method Details

    • getProxyServer

      public static ProxyServer getProxyServer(AsyncHttpClientConfig config, Request request)
      Parameters:
      config - the global config
      request - the request
      Returns:
      the proxy server to be used for this request (can be null)
    • avoidProxy

      public static boolean avoidProxy(ProxyServer proxyServer, Request request)
      See Also:
    • avoidProxy

      public static boolean avoidProxy(ProxyServer proxyServer, String hostname)
      Checks whether proxy should be used according to nonProxyHosts settings of it, or we want to go directly to target host. If null proxy is passed in, this method returns true -- since there is NO proxy, we should avoid to use it. Simple hostname pattern matching using "*" are supported, but only as prefixes. See http://download.oracle.com/javase/1.4.2/docs/guide/net/properties.html
      Parameters:
      proxyServer -
      hostname - the hostname
      Returns:
      true if we have to avoid proxy use (obeying non-proxy hosts settings), false otherwise.
    • createProxyServerSelector

      public static ProxyServerSelector createProxyServerSelector(Properties properties)
      Creates a proxy server instance from the given properties. Currently the default http.* proxy properties are supported as well as properties specific for AHC.
      Parameters:
      properties - the properties to evaluate. Must not be null.
      Returns:
      a ProxyServer instance or null, if no valid properties were set.
      See Also:
    • getJdkDefaultProxyServerSelector

      public static ProxyServerSelector getJdkDefaultProxyServerSelector()
      Get a proxy server selector based on the JDK default proxy selector.
      Returns:
      The proxy server selector.
    • createProxyServerSelector

      public static ProxyServerSelector createProxyServerSelector(ProxySelector proxySelector)
      Create a proxy server selector based on the passed in JDK proxy selector.
      Parameters:
      proxySelector - The proxy selector to use. Must not be null.
      Returns:
      The proxy server selector.
    • createProxyServerSelector

      public static ProxyServerSelector createProxyServerSelector(ProxyServer proxyServer)
      Create a proxy server selector that always selects a single proxy server.
      Parameters:
      proxyServer - The proxy server to select.
      Returns:
      The proxy server selector.