ProxyOptions Class
- java.
lang. Object - com.
azure. core. http. ProxyOptions
- com.
public class ProxyOptions
Represents the proxy configuration to be used in HTTP clients.
This class encapsulates the proxy settings, including the proxy type, address, and optional credentials. It provides methods to set and get these properties.
This class is useful when you want to configure a proxy for an HTTP client. For example, you can use it to create a proxy with specific credentials, or to specify hosts that should bypass the proxy.
Note: This class provides a Type enum to represent the proxy type, which can be HTTP, SOCKS4, or SOCKS5.
Constructor Summary
Constructor | Description |
---|---|
ProxyOptions(ProxyOptions.Type type, InetSocketAddress address) |
Creates Proxy |
Method Summary
Modifier and Type | Method and Description |
---|---|
static
Proxy |
fromConfiguration(Configuration configuration)
Attempts to load a proxy from the configuration. |
static
Proxy |
fromConfiguration(Configuration configuration, boolean createUnresolved)
Attempts to load a proxy from the environment. |
Inet |
getAddress()
Gets the address of the proxy. |
String |
getNonProxyHosts()
Gets the host that bypass the proxy. |
String |
getPassword()
Gets the proxy password. |
Type |
getType()
Gets the type of the proxy. |
String |
getUsername()
Gets the proxy username. |
Proxy |
setCredentials(String username, String password)
Set the proxy credentials. |
Proxy |
setNonProxyHosts(String nonProxyHosts)
Sets the hosts which bypass the proxy. |
Methods inherited from java.lang.Object
Constructor Details
ProxyOptions
public ProxyOptions(ProxyOptions.Type type, InetSocketAddress address)
Creates ProxyOptions.
Parameters:
Method Details
fromConfiguration
public static ProxyOptions fromConfiguration(Configuration configuration)
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
Azure proxy configurations will be preferred over Java proxy configurations as they are more closely scoped to the purpose of the SDK. Additionally, more secure protocols, HTTPS vs HTTP, will be preferred.
null
will be returned if no proxy was found in the environment.
Parameters:
null
is passed then getGlobalConfiguration() will be used.
Returns:
null
will be returned.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
. When createUnresolved
is true resolving getAddress() 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
Azure proxy configurations will be preferred over Java proxy configurations as they are more closely scoped to the purpose of the SDK. Additionally, more secure protocols, HTTPS vs HTTP, will be preferred.
null
will be returned if no proxy was found in the environment.
Parameters:
null
is passed then getGlobalConfiguration() will be used. If NONE is passed IllegalArgumentException will be thrown.
Returns:
null
will be returned.getAddress
public InetSocketAddress getAddress()
Gets the address of the proxy.
Returns:
getNonProxyHosts
public String getNonProxyHosts()
Gets the host that bypass the proxy.
Returns:
getPassword
public String getPassword()
Gets the proxy password.
Returns:
getType
public ProxyOptions.Type getType()
Gets the type of the proxy.
Returns:
getUsername
public String getUsername()
Gets the proxy username.
Returns:
setCredentials
public ProxyOptions setCredentials(String username, String password)
Set the proxy credentials.
Parameters:
Returns:
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:
Returns:
Applies to
Azure SDK for Java