Package com.azure.core.http
Class ProxyOptions
java.lang.Object
com.azure.core.http.ProxyOptions
This represents proxy configuration to be used in http clients..
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionProxyOptions
(ProxyOptions.Type type, InetSocketAddress address) Creates ProxyOptions. -
Method Summary
Modifier and TypeMethodDescriptionstatic ProxyOptions
fromConfiguration
(Configuration configuration) Attempts to load a proxy from the configuration.static ProxyOptions
fromConfiguration
(Configuration configuration, boolean createUnresolved) Attempts to load a proxy from the environment.getType()
setCredentials
(String username, String password) Set the proxy credentials.setNonProxyHosts
(String nonProxyHosts) Sets the hosts which bypass the proxy.
-
Constructor Details
-
ProxyOptions
Creates ProxyOptions.- Parameters:
type
- the proxy typeaddress
- the proxy address (ip and port number)
-
-
Method Details
-
setCredentials
Set the proxy credentials.- Parameters:
username
- proxy user namepassword
- proxy password- Returns:
- the updated ProxyOptions object
-
setNonProxyHosts
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
- Returns:
- the address of the proxy.
-
getType
- Returns:
- the type of the proxy.
-
getUsername
- Returns:
- the proxy user name.
-
getPassword
- Returns:
- the proxy password.
-
getNonProxyHosts
- Returns:
- the hosts that bypass the proxy.
-
fromConfiguration
Attempts to load a proxy from the configuration.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.- Returns:
- A
ProxyOptions
reflecting a proxy loaded from the environment, if no proxy is foundnull
will be returned.
-
fromConfiguration
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.
-