Package org.htmlunit
Class ProxyConfig
java.lang.Object
org.htmlunit.ProxyConfig
- All Implemented Interfaces:
Serializable
Class which centralizes proxy configuration, in an effort to reduce clutter in the
WebClient
class. One instance of this class exists for each WebClient instance.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance.ProxyConfig(String proxyHost, int proxyPort, String proxyScheme) Creates a new instance.ProxyConfig(String proxyHost, int proxyPort, String proxyScheme, boolean isSocks) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHostsToProxyBypass(String pattern) Any hosts matched by the specified regular expression pattern will bypass the configured proxy.protected StringReturns the proxy auto-config content.Returns the proxy auto-config URL.Returns the proxy host used to perform HTTP requests.intReturns the proxy port used to perform HTTP requests.Returns the proxy scheme used to perform HTTP requests.booleanReturns whether SOCKS proxy or not.voidremoveHostsFromProxyBypass(String pattern) Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.protected voidsetProxyAutoConfigContent(String proxyAutoConfigContent) Sets the proxy auto-config content.voidsetProxyAutoConfigUrl(String proxyAutoConfigUrl) Sets the proxy auto-config URL.voidsetProxyHost(String proxyHost) Sets the proxy host used to perform HTTP requests.voidsetProxyPort(int proxyPort) Sets the proxy port used to perform HTTP requests.voidsetProxyPort(String proxyScheme) Sets the proxy scheme used to perform HTTP requests.voidsetSocksProxy(boolean isSocksProxy) Sets whether SOCKS proxy or not.protected booleanshouldBypassProxy(String hostname) Returnstrueif the host with the specified hostname should be accessed bypassing the configured proxy.
-
Constructor Details
-
ProxyConfig
public ProxyConfig()Creates a new instance. -
ProxyConfig
Creates a new instance.- Parameters:
proxyHost- the proxy hostproxyPort- the proxy portproxyScheme- the scheme http/https; null defaults to http
-
ProxyConfig
Creates a new instance.- Parameters:
proxyHost- the proxy hostproxyPort- the proxy portproxyScheme- the scheme http/httpsisSocks- whether SOCKS proxy or not
-
-
Method Details
-
getProxyHost
Returns the proxy host used to perform HTTP requests.- Returns:
- the proxy host used to perform HTTP requests
-
setProxyHost
Sets the proxy host used to perform HTTP requests.- Parameters:
proxyHost- the proxy host used to perform HTTP requests
-
getProxyPort
public int getProxyPort()Returns the proxy port used to perform HTTP requests.- Returns:
- the proxy port used to perform HTTP requests
-
setProxyPort
public void setProxyPort(int proxyPort) Sets the proxy port used to perform HTTP requests.- Parameters:
proxyPort- the proxy port used to perform HTTP requests
-
getProxyScheme
Returns the proxy scheme used to perform HTTP requests.- Returns:
- the proxy scheme used to perform HTTP requests
-
setProxyPort
Sets the proxy scheme used to perform HTTP requests.- Parameters:
proxyScheme- the proxy scheme used to perform HTTP requests
-
isSocksProxy
public boolean isSocksProxy()Returns whether SOCKS proxy or not.- Returns:
- whether SOCKS proxy or not
-
setSocksProxy
public void setSocksProxy(boolean isSocksProxy) Sets whether SOCKS proxy or not.- Parameters:
isSocksProxy- whether SOCKS proxy or not
-
addHostsToProxyBypass
Any hosts matched by the specified regular expression pattern will bypass the configured proxy.- Parameters:
pattern- a regular expression pattern that matches the hostnames of the hosts which should bypass the configured proxy.- See Also:
-
removeHostsFromProxyBypass
Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.- Parameters:
pattern- the previously added regular expression pattern- See Also:
-
shouldBypassProxy
Returnstrueif the host with the specified hostname should be accessed bypassing the configured proxy.- Parameters:
hostname- the name of the host to check- Returns:
trueif the host with the specified hostname should be accessed bypassing the configured proxy,falseotherwise.
-
getProxyAutoConfigUrl
Returns the proxy auto-config URL.- Returns:
- the proxy auto-config URL
-
setProxyAutoConfigUrl
Sets the proxy auto-config URL.- Parameters:
proxyAutoConfigUrl- the proxy auto-config URL
-
getProxyAutoConfigContent
Returns the proxy auto-config content.- Returns:
- the proxy auto-config content
-
setProxyAutoConfigContent
Sets the proxy auto-config content.- Parameters:
proxyAutoConfigContent- the proxy auto-config content
-