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 class
ProxyOptions.Type
The 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 ProxyOptions
fromConfiguration(Configuration configuration)
Attempts to load a proxy from the environment.static ProxyOptions
fromConfiguration(Configuration configuration, boolean createUnresolved)
Attempts to load a proxy from the environment.InetSocketAddress
getAddress()
String
getNonProxyHosts()
String
getPassword()
ProxyOptions.Type
getType()
String
getUsername()
ProxyOptions
setCredentials(String username, String password)
Set the proxy credentials.ProxyOptions
setNonProxyHosts(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
null
will be returned if no proxy was found in the environment.- Parameters:
configuration
- TheConfiguration
that is used to load proxy configurations from the environment. Ifnull
is passed thenConfiguration.getGlobalConfiguration()
will be used. IfConfiguration.NONE
is passedIllegalArgumentException
will be thrown.- Returns:
- A
ProxyOptions
reflecting a proxy loaded from the environment, if no proxy is foundnull
will be returned. - Throws:
IllegalArgumentException
- Ifconfiguration
isConfiguration.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
. WhencreateUnresolved
is 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
null
will be returned if no proxy was found in the environment.- Parameters:
configuration
- TheConfiguration
that is used to load proxy configurations from the environment. Ifnull
is passed thenConfiguration.getGlobalConfiguration()
will be used. IfConfiguration.NONE
is passedIllegalArgumentException
will be thrown.createUnresolved
- Flag determining whether the returnedProxyOptions
is unresolved.- Returns:
- A
ProxyOptions
reflecting a proxy loaded from the environment, if no proxy is foundnull
will be returned. - Throws:
IllegalArgumentException
- Ifconfiguration
isConfiguration.NONE
.
-
-