com.ning.http.util
Class ProxyUtils

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

public final class ProxyUtils
extends Object

Utilities for Proxy handling.

Author:
cstamas

Field Summary
static String PROXY_HOST
          The host to use as proxy.
static String PROXY_NONPROXYHOSTS
          A specification of non-proxy hosts.
static String PROXY_PASSWORD
          The password to use for authentication for the proxy server.
static String PROXY_PORT
          The port to use for the proxy.
static String PROXY_PROTOCOL
          The protocol to use.
static String PROXY_USER
          The username to use for authentication for the proxy server.
 
Method Summary
static boolean avoidProxy(ProxyServer proxyServer, Request request)
           
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.
static ProxyServerSelector createProxyServerSelector(Properties properties)
          Creates a proxy server instance from the given properties.
static ProxyServerSelector createProxyServerSelector(ProxySelector proxySelector)
          Create a proxy server selector based on the passed in JDK proxy selector.
static ProxyServerSelector createProxyServerSelector(ProxyServer proxyServer)
          Create a proxy server selector that always selects a single proxy server.
static ProxyServerSelector getJdkDefaultProxyServerSelector()
          Get a proxy server selector based on the JDK default proxy selector.
static ProxyServer getProxyServer(AsyncHttpClientConfig config, Request request)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROXY_HOST

public static final String PROXY_HOST
The host to use as proxy.

See Also:
Constant Field Values

PROXY_PORT

public static final String PROXY_PORT
The port to use for the proxy.

See Also:
Constant Field Values

PROXY_PROTOCOL

public static final String PROXY_PROTOCOL
The protocol to use. Is mapped to the ProxyServer.Protocol enum.

See Also:
Constant Field Values

PROXY_NONPROXYHOSTS

public static final String PROXY_NONPROXYHOSTS
A specification of non-proxy hosts. See http://download.oracle.com/javase/1.4.2/docs/guide/net/properties.html

See Also:
Constant Field Values

PROXY_USER

public static final String PROXY_USER
The username to use for authentication for the proxy server.

See Also:
Constant Field Values

PROXY_PASSWORD

public static final String PROXY_PASSWORD
The password to use for authentication for the proxy server.

See Also:
Constant Field Values
Method Detail

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(ProxyServer, String)

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:
Networking Properties, PROXY_HOST, PROXY_PORT, PROXY_PROTOCOL, PROXY_NONPROXYHOSTS

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.


Copyright © 2014. All Rights Reserved.