Package com.azure.core.http
Class ProxyOptions
- java.lang.Object
-
- com.azure.core.http.ProxyOptions
-
public class ProxyOptions extends Object
This represents proxy configuration to be used in http clients..
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProxyOptions.TypeThe type of the proxy.
-
Constructor Summary
Constructors Constructor Description ProxyOptions(ProxyOptions.Type type, InetSocketAddress address)Creates ProxyOptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ProxyOptionsfromConfiguration(Configuration configuration)Attempts to load a proxy from the environment.static ProxyOptionsfromConfiguration(Configuration configuration, boolean createUnresolved)Attempts to load a proxy from the environment.InetSocketAddressgetAddress()StringgetNonProxyHosts()StringgetPassword()ProxyOptions.TypegetType()StringgetUsername()ProxyOptionssetCredentials(String username, String password)Set the proxy credentials.ProxyOptionssetNonProxyHosts(String nonProxyHosts)Sets the hosts which bypass the proxy.
-
-
-
Constructor Detail
-
ProxyOptions
public ProxyOptions(ProxyOptions.Type type, InetSocketAddress address)
Creates ProxyOptions.- Parameters:
type- the proxy typeaddress- the proxy address (ip and port number)
-
-
Method Detail
-
setCredentials
public ProxyOptions setCredentials(String username, String password)
Set the proxy credentials.- Parameters:
username- proxy user namepassword- proxy password- Returns:
- the updated ProxyOptions object
-
setNonProxyHosts
public ProxyOptions setNonProxyHosts(String nonProxyHosts)
Sets the hosts which bypass the proxy.The expected format of the passed string is a
'|'delimited list of hosts which should bypass the proxy. Individual host strings may contain regex characters such as'*'.- Parameters:
nonProxyHosts- Hosts that bypass the proxy.- Returns:
- the updated ProxyOptions object
-
getAddress
public InetSocketAddress getAddress()
- Returns:
- the address of the proxy.
-
getType
public ProxyOptions.Type getType()
- Returns:
- the type of the proxy.
-
getUsername
public String getUsername()
- Returns:
- the proxy user name.
-
getPassword
public String getPassword()
- Returns:
- the proxy password.
-
getNonProxyHosts
public String getNonProxyHosts()
- Returns:
- the hosts that bypass the proxy.
-
fromConfiguration
public static ProxyOptions fromConfiguration(Configuration configuration)
Attempts to load a proxy from the environment.If a proxy is found and loaded the proxy address is DNS resolved.
Environment configurations are loaded in this order:
- Azure HTTPS
- Azure HTTP
- Java HTTPS
- Java HTTP
nullwill be returned if no proxy was found in the environment.- Parameters:
configuration- TheConfigurationthat is used to load proxy configurations from the environment. Ifnullis passed thenConfiguration.getGlobalConfiguration()will be used. IfConfiguration.NONEis passedIllegalArgumentExceptionwill be thrown.- Returns:
- A
ProxyOptionsreflecting a proxy loaded from the environment, if no proxy is foundnullwill be returned. - Throws:
IllegalArgumentException- IfconfigurationisConfiguration.NONE.
-
fromConfiguration
public static ProxyOptions fromConfiguration(Configuration configuration, boolean createUnresolved)
Attempts to load a proxy from the environment.If a proxy is found and loaded, the proxy address is DNS resolved based on
createUnresolved. WhencreateUnresolvedis true resolvinggetAddress()may be required before using the address in network calls.Environment configurations are loaded in this order:
- Azure HTTPS
- Azure HTTP
- Java HTTPS
- Java HTTP
nullwill be returned if no proxy was found in the environment.- Parameters:
configuration- TheConfigurationthat is used to load proxy configurations from the environment. Ifnullis passed thenConfiguration.getGlobalConfiguration()will be used. IfConfiguration.NONEis passedIllegalArgumentExceptionwill be thrown.createUnresolved- Flag determining whether the returnedProxyOptionsis unresolved.- Returns:
- A
ProxyOptionsreflecting a proxy loaded from the environment, if no proxy is foundnullwill be returned. - Throws:
IllegalArgumentException- IfconfigurationisConfiguration.NONE.
-
-