public class

ProxyUtils

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

Class Overview

Utilities for Proxy handling.

Summary

Constants
String PROXY_HOST The host to use as proxy.
String PROXY_NONPROXYHOSTS A specification of non-proxy hosts.
String PROXY_PASSWORD The password to use for authentication for the proxy server.
String PROXY_PORT The port to use for the proxy.
String PROXY_PROTOCOL The protocol to use.
String PROXY_USER The username to use for authentication for the proxy server.
Public Constructors
ProxyUtils()
Public Methods
static boolean avoidProxy(ProxyServer proxyServer, Request request)
Checks whether proxy should be used according to nonProxyHosts settings of it, or we want to go directly to target host.
static boolean avoidProxy(ProxyServer proxyServer, String target)
Checks whether proxy should be used according to nonProxyHosts settings of it, or we want to go directly to target host.
static ProxyServer createProxy(Properties properties)
Creates a proxy server instance from the given properties.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String PROXY_HOST

The host to use as proxy.

Constant Value: "http.proxyHost"

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

Constant Value: "http.nonProxyHosts"

public static final String PROXY_PASSWORD

The password to use for authentication for the proxy server.

Constant Value: "com.ning.http.client.AsyncHttpClientConfig.proxy.password"

public static final String PROXY_PORT

The port to use for the proxy.

Constant Value: "http.proxyPort"

public static final String PROXY_PROTOCOL

The protocol to use. Is mapped to the ProxyServer.Protocol enum.

Constant Value: "com.ning.http.client.AsyncHttpClientConfig.proxy.protocol"

public static final String PROXY_USER

The username to use for authentication for the proxy server.

Constant Value: "com.ning.http.client.AsyncHttpClientConfig.proxy.user"

Public Constructors

public ProxyUtils ()

Public Methods

public static boolean avoidProxy (ProxyServer proxyServer, Request request)

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

Returns
  • true if we have to avoid proxy use (obeying non-proxy hosts settings), false otherwise.

public static boolean avoidProxy (ProxyServer proxyServer, String target)

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
target the hostname
Returns
  • true if we have to avoid proxy use (obeying non-proxy hosts settings), false otherwise.

public static ProxyServer createProxy (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.