Package com.ning.http.util
Class ProxyUtils
java.lang.Object
com.ning.http.util.ProxyUtils
Utilities for Proxy handling.
- Author:
- cstamas
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe host to use as proxy.static final StringA specification of non-proxy hosts.static final StringThe password to use for authentication for the proxy server.static final StringThe port to use for the proxy.static final StringThe protocol to use.static final StringThe username to use for authentication for the proxy server. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanavoidProxy(ProxyServer proxyServer, Request request) static booleanavoidProxy(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 ProxyServerSelectorcreateProxyServerSelector(ProxyServer proxyServer) Create a proxy server selector that always selects a single proxy server.static ProxyServerSelectorcreateProxyServerSelector(ProxySelector proxySelector) Create a proxy server selector based on the passed in JDK proxy selector.static ProxyServerSelectorcreateProxyServerSelector(Properties properties) Creates a proxy server instance from the given properties.static ProxyServerSelectorGet a proxy server selector based on the JDK default proxy selector.static ProxyServergetProxyServer(AsyncHttpClientConfig config, Request request)
-
Field Details
-
PROXY_HOST
The host to use as proxy.- See Also:
-
PROXY_PORT
The port to use for the proxy.- See Also:
-
PROXY_PROTOCOL
The protocol to use. Is mapped to theProxyServer.Protocolenum.- See Also:
-
PROXY_NONPROXYHOSTS
A specification of non-proxy hosts. See http://download.oracle.com/javase/1.4.2/docs/guide/net/properties.html- See Also:
-
PROXY_USER
The username to use for authentication for the proxy server.- See Also:
-
PROXY_PASSWORD
The password to use for authentication for the proxy server.- See Also:
-
-
Method Details
-
getProxyServer
- Parameters:
config- the global configrequest- the request- Returns:
- the proxy server to be used for this request (can be null)
-
avoidProxy
- See Also:
-
avoidProxy
Checks whether proxy should be used according to nonProxyHosts settings of it, or we want to go directly to target host. Ifnullproxy 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
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
Get a proxy server selector based on the JDK default proxy selector.- Returns:
- The proxy server selector.
-
createProxyServerSelector
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
Create a proxy server selector that always selects a single proxy server.- Parameters:
proxyServer- The proxy server to select.- Returns:
- The proxy server selector.
-