Package org.htmlunit
Class ProxyConfig
- java.lang.Object
-
- org.htmlunit.ProxyConfig
-
- All Implemented Interfaces:
java.io.Serializable
public class ProxyConfig extends java.lang.Object implements java.io.SerializableClass which centralizes proxy configuration, in an effort to reduce clutter in theWebClientclass. One instance of this class exists for eachWebClientinstance.- See Also:
WebClientOptions.getProxyConfig(), Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ProxyConfig()Creates a new instance.ProxyConfig(java.lang.String proxyHost, int proxyPort, java.lang.String proxyScheme)Creates a new instance.ProxyConfig(java.lang.String proxyHost, int proxyPort, java.lang.String proxyScheme, boolean isSocks)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHostsToProxyBypass(java.lang.String pattern)Any hosts matched by the specified regular expression pattern will bypass the configured proxy.protected java.lang.StringgetProxyAutoConfigContent()Returns the proxy auto-config content.java.lang.StringgetProxyAutoConfigUrl()Returns the proxy auto-config URL.java.lang.StringgetProxyHost()Returns the proxy host used to perform HTTP requests.intgetProxyPort()Returns the proxy port used to perform HTTP requests.java.lang.StringgetProxyScheme()Returns the proxy scheme used to perform HTTP requests.booleanisSocksProxy()Returns whether SOCKS proxy or not.voidremoveHostsFromProxyBypass(java.lang.String pattern)Any hosts matched by the specified regular expression pattern will no longer bypass the configured proxy.protected voidsetProxyAutoConfigContent(java.lang.String proxyAutoConfigContent)Sets the proxy auto-config content.voidsetProxyAutoConfigUrl(java.lang.String proxyAutoConfigUrl)Sets the proxy auto-config URL.voidsetProxyHost(java.lang.String proxyHost)Sets the proxy host used to perform HTTP requests.voidsetProxyPort(int proxyPort)Sets the proxy port used to perform HTTP requests.voidsetProxyPort(java.lang.String proxyScheme)Sets the proxy scheme used to perform HTTP requests.voidsetSocksProxy(boolean isSocksProxy)Sets whether SOCKS proxy or not.protected booleanshouldBypassProxy(java.lang.String hostname)Returnstrueif the host with the specified hostname should be accessed bypassing the configured proxy.
-
-
-
Constructor Detail
-
ProxyConfig
public ProxyConfig()
Creates a new instance.
-
ProxyConfig
public ProxyConfig(java.lang.String proxyHost, int proxyPort, java.lang.String proxyScheme)Creates a new instance.- Parameters:
proxyHost- the proxy hostproxyPort- the proxy portproxyScheme- the scheme http/https; null defaults to http
-
ProxyConfig
public ProxyConfig(java.lang.String proxyHost, int proxyPort, java.lang.String proxyScheme, boolean isSocks)Creates a new instance.- Parameters:
proxyHost- the proxy hostproxyPort- the proxy portproxyScheme- the scheme http/httpsisSocks- whether SOCKS proxy or not
-
-
Method Detail
-
getProxyHost
public java.lang.String getProxyHost()
Returns the proxy host used to perform HTTP requests.- Returns:
- the proxy host used to perform HTTP requests
-
setProxyHost
public void setProxyHost(java.lang.String proxyHost)
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
public java.lang.String getProxyScheme()
Returns the proxy scheme used to perform HTTP requests.- Returns:
- the proxy scheme used to perform HTTP requests
-
setProxyPort
public void setProxyPort(java.lang.String proxyScheme)
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
public void addHostsToProxyBypass(java.lang.String pattern)
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:
Pattern
-
removeHostsFromProxyBypass
public void removeHostsFromProxyBypass(java.lang.String pattern)
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:
Pattern
-
shouldBypassProxy
protected boolean shouldBypassProxy(java.lang.String hostname)
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
public java.lang.String getProxyAutoConfigUrl()
Returns the proxy auto-config URL.- Returns:
- the proxy auto-config URL
-
setProxyAutoConfigUrl
public void setProxyAutoConfigUrl(java.lang.String proxyAutoConfigUrl)
Sets the proxy auto-config URL.- Parameters:
proxyAutoConfigUrl- the proxy auto-config URL
-
getProxyAutoConfigContent
protected java.lang.String getProxyAutoConfigContent()
Returns the proxy auto-config content.- Returns:
- the proxy auto-config content
-
setProxyAutoConfigContent
protected void setProxyAutoConfigContent(java.lang.String proxyAutoConfigContent)
Sets the proxy auto-config content.- Parameters:
proxyAutoConfigContent- the proxy auto-config content
-
-