public class WebClientOptions extends Object implements Serializable
WebClient
.Constructor and Description |
---|
WebClientOptions() |
Modifier and Type | Method and Description |
---|---|
int |
getHistoryPageCacheLimit()
Returns the maximum number of
pages to cache in history. |
int |
getHistorySizeLimit()
Returns the maximum number of
pages kept in WebWindow.getHistory() . |
String |
getHomePage()
Returns the client's current homepage.
|
InetAddress |
getLocalAddress()
Returns local address to be used for request execution.
|
int |
getMaxInMemory()
Returns the maximum bytes to have in memory, after which the content is saved to a file.
|
boolean |
getPrintContentOnFailingStatusCode()
Deprecated.
as of 2.27, please use
isPrintContentOnFailingStatusCode() |
ProxyConfig |
getProxyConfig()
Returns the proxy configuration for this client.
|
int |
getScreenHeight()
Returns the screen height.
|
int |
getScreenWidth()
Returns the screen width.
|
char[] |
getSSLClientCertificatePassword()
Gets the SSLClientCertificatePassword.
|
KeyStore |
getSSLClientCertificateStore()
Gets the SSLClientCertificateStore.
|
String[] |
getSSLClientCipherSuites()
Gets the cipher suites enabled for use on SSL connections.
|
String[] |
getSSLClientProtocols()
Gets the protocol versions enabled for use on SSL connections.
|
String |
getSSLInsecureProtocol()
Gets the SSL protocol, to be used only when
setUseInsecureSSL(boolean) is set to true . |
KeyStore |
getSSLTrustStore()
Gets the SSL TrustStore.
|
int |
getTimeout()
Gets the timeout value for the
WebConnection . |
int |
getWebSocketMaxBinaryMessageBufferSize() |
int |
getWebSocketMaxBinaryMessageSize() |
int |
getWebSocketMaxTextMessageBufferSize() |
int |
getWebSocketMaxTextMessageSize() |
boolean |
isActiveXNative()
Returns whether native ActiveX components are allowed or no.
|
boolean |
isAppletEnabled()
Returns
true if Applet are enabled. |
boolean |
isCssEnabled()
Returns
true if CSS is enabled. |
boolean |
isDoNotTrackEnabled()
Returns
true if "Do Not Track" is enabled. |
boolean |
isDownloadImages()
Returns whether to automatically download images by default, or not.
|
boolean |
isGeolocationEnabled()
Returns
true if Geolocation is enabled. |
boolean |
isJavaScriptEnabled()
Returns
true if JavaScript is enabled and the script engine was loaded successfully. |
boolean |
isPopupBlockerEnabled()
Returns
true if the popup window blocker is enabled. |
boolean |
isPrintContentOnFailingStatusCode()
Returns
true if the content of the resulting document will be printed to
the console in the event of a failing response code. |
boolean |
isRedirectEnabled()
Returns whether or not redirections will be followed automatically on receipt of
a redirect status code from the server.
|
boolean |
isThrowExceptionOnFailingStatusCode()
Returns
true if an exception will be thrown in the event of a failing response code. |
boolean |
isThrowExceptionOnScriptError()
Indicates if an exception should be thrown when a script execution fails
(the default) or if it should be caught and just logged to allow page
execution to continue.
|
boolean |
isUseInsecureSSL()
Indicates if insecure SSL should be used.
|
void |
setActiveXNative(boolean allow)
Sets whether to allow native ActiveX or no.
|
void |
setAppletEnabled(boolean enabled)
Enables/disables Applet support.
|
void |
setCssEnabled(boolean enabled)
Enables/disables CSS support.
|
void |
setDoNotTrackEnabled(boolean enabled)
Enables/disables "Do Not Track" support.
|
void |
setDownloadImages(boolean downloadImages)
Sets whether to automatically download images by default, or not.
|
void |
setGeolocationEnabled(boolean enabled)
Enables/disables Geolocation support.
|
void |
setHistoryPageCacheLimit(int historyPageCacheLimit)
Sets the maximum number of
pages to cache in history. |
void |
setHistorySizeLimit(int historySizeLimit)
Sets the History size limit.
|
void |
setHomePage(String homePage)
Sets the client's homepage.
|
void |
setJavaScriptEnabled(boolean enabled)
Enables/disables JavaScript support.
|
void |
setLocalAddress(InetAddress localAddress)
Sets the local address to be used for request execution.
|
void |
setMaxInMemory(int maxInMemory)
Sets the maximum bytes to have in memory, after which the content is saved to a file.
|
void |
setPopupBlockerEnabled(boolean enabled)
Enable/disable the popup window blocker.
|
void |
setPrintContentOnFailingStatusCode(boolean enabled)
Specify whether or not the content of the resulting document will be
printed to the console in the event of a failing response code.
|
void |
setProxyConfig(ProxyConfig proxyConfig)
Sets the proxy configuration for this client.
|
void |
setRedirectEnabled(boolean enabled)
Sets whether or not redirections will be followed automatically on receipt of a redirect
status code from the server.
|
void |
setScreenHeight(int screenHeight)
Sets the screen height.
|
void |
setScreenWidth(int screenWidth)
Sets the screen width.
|
void |
setSSLClientCertificate(InputStream certificateInputStream,
String certificatePassword,
String certificateType)
Sets the SSL client certificate to use.
|
void |
setSSLClientCertificate(URL certificateUrl,
String certificatePassword,
String certificateType)
Sets the SSL client certificate to use.
|
void |
setSSLClientCipherSuites(String[] sslClientCipherSuites)
Sets the cipher suites enabled for use on SSL connections,
null to use default ones. |
void |
setSSLClientProtocols(String[] sslClientProtocols)
Sets the protocol versions enabled for use on SSL connections,
null to use default ones. |
void |
setSSLInsecureProtocol(String sslInsecureProtocol)
Sets the SSL protocol, used only when
setUseInsecureSSL(boolean) is set to true . |
void |
setSSLTrustStore(URL sslTrustStoreUrl,
String sslTrustStorePassword,
String sslTrustStoreType)
Sets the SSL server certificate trust store.
|
void |
setThrowExceptionOnFailingStatusCode(boolean enabled)
Specify whether or not an exception will be thrown in the event of a
failing status code.
|
void |
setThrowExceptionOnScriptError(boolean enabled)
Changes the behavior of this webclient when a script error occurs.
|
void |
setTimeout(int timeout)
Sets the timeout of the
WebConnection . |
void |
setUseInsecureSSL(boolean useInsecureSSL)
If set to
true , the client will accept connections to any host, regardless of
whether they have valid certificates or not. |
void |
setWebSocketMaxBinaryMessageBufferSize(int webSocketMaxBinaryMessageBufferSize)
Sets the WebSocket maxBinaryMessageBufferSize.
|
void |
setWebSocketMaxBinaryMessageSize(int webSocketMaxBinaryMessageSize)
Sets the WebSocket maxBinaryMessageSize.
|
void |
setWebSocketMaxTextMessageBufferSize(int webSocketMaxTextMessageBufferSize)
Sets the WebSocket maxTextMessageBufferSize.
|
void |
setWebSocketMaxTextMessageSize(int webSocketMaxTextMessageSize)
Sets the WebSocket maxTextMessageSize.
|
public void setUseInsecureSSL(boolean useInsecureSSL)
true
, the client will accept connections to any host, regardless of
whether they have valid certificates or not. This is especially useful when you are trying to
connect to a server with expired or corrupt certificates.useInsecureSSL
- whether or not to use insecure SSLpublic boolean isUseInsecureSSL()
true
if insecure SSL should be used. Default is false
.public void setRedirectEnabled(boolean enabled)
enabled
- true to enable automatic redirectionpublic boolean isRedirectEnabled()
public void setSSLClientCertificate(InputStream certificateInputStream, String certificatePassword, String certificateType)
KeyStore
.
If the web server requires Renegotiation, you have to set system property
"sun.security.ssl.allowUnsafeRenegotiation" to true, as hinted in
TLS Renegotiation Issue.certificateInputStream
- the input stream which represents the certificatecertificatePassword
- the certificate passwordcertificateType
- the type of certificate, usually jks
or pkcs12
public void setSSLClientCertificate(URL certificateUrl, String certificatePassword, String certificateType)
KeyStore
.
If the web server requires Renegotiation, you have to set system property
"sun.security.ssl.allowUnsafeRenegotiation" to true, as hinted in
TLS Renegotiation Issue.certificateUrl
- the URL which locates the certificatecertificatePassword
- the certificate passwordcertificateType
- the type of certificate, usually jks
or pkcs12
public KeyStore getSSLClientCertificateStore()
public char[] getSSLClientCertificatePassword()
public String[] getSSLClientProtocols()
setSSLClientProtocols(String[])
public void setSSLClientProtocols(String[] sslClientProtocols)
null
to use default ones.sslClientProtocols
- the protocol versionsSSLSocket.setEnabledProtocols(String[])
,
getSSLClientProtocols()
public String[] getSSLClientCipherSuites()
setSSLClientCipherSuites(String[])
public void setSSLClientCipherSuites(String[] sslClientCipherSuites)
null
to use default ones.sslClientCipherSuites
- the cipher suitesSSLSocket.setEnabledCipherSuites(String[])
,
getSSLClientCipherSuites()
public void setJavaScriptEnabled(boolean enabled)
enabled
- true
to enable JavaScript supportpublic boolean isJavaScriptEnabled()
true
if JavaScript is enabled and the script engine was loaded successfully.true
if JavaScript is enabledpublic void setCssEnabled(boolean enabled)
enabled
- true
to enable CSS supportpublic boolean isCssEnabled()
true
if CSS is enabled.true
if CSS is enabledpublic void setAppletEnabled(boolean enabled)
Note: Applet support is experimental and minimal
enabled
- true
to enable Applet supportpublic boolean isAppletEnabled()
true
if Applet are enabled.true
if Applet is enabledpublic void setPopupBlockerEnabled(boolean enabled)
true
, window.open() has no effect and
returns null
.enabled
- true
to enable the popup window blockerpublic boolean isPopupBlockerEnabled()
true
if the popup window blocker is enabled.true
if the popup window blocker is enabledpublic void setGeolocationEnabled(boolean enabled)
enabled
- true
to enable Geolocation supportpublic boolean isGeolocationEnabled()
true
if Geolocation is enabled.true
if Geolocation is enabledpublic void setDoNotTrackEnabled(boolean enabled)
enabled
- true
to enable "Do Not Track" supportpublic boolean isDoNotTrackEnabled()
true
if "Do Not Track" is enabled.true
if "Do Not Track" is enabledpublic void setPrintContentOnFailingStatusCode(boolean enabled)
enabled
- True to enable this feature@Deprecated public boolean getPrintContentOnFailingStatusCode()
isPrintContentOnFailingStatusCode()
true
if the content of the resulting document will be printed to
the console in the event of a failing response code.true
if the content of the resulting document will be printed to
the console in the event of a failing response codesetPrintContentOnFailingStatusCode(boolean)
public boolean isPrintContentOnFailingStatusCode()
true
if the content of the resulting document will be printed to
the console in the event of a failing response code.true
if the content of the resulting document will be printed to
the console in the event of a failing response codesetPrintContentOnFailingStatusCode(boolean)
public void setThrowExceptionOnFailingStatusCode(boolean enabled)
enabled
- true
to enable this featurepublic boolean isThrowExceptionOnFailingStatusCode()
true
if an exception will be thrown in the event of a failing response code.true
if an exception will be thrown in the event of a failing response codesetThrowExceptionOnFailingStatusCode(boolean)
public boolean isThrowExceptionOnScriptError()
true
if an exception is thrown on script error (the default)public void setThrowExceptionOnScriptError(boolean enabled)
enabled
- indicates if exception should be thrown or notpublic void setActiveXNative(boolean allow)
allow
- whether to allow or nopublic boolean isActiveXNative()
public String getHomePage()
public void setHomePage(String homePage)
homePage
- the new homepage URLpublic ProxyConfig getProxyConfig()
public void setProxyConfig(ProxyConfig proxyConfig)
proxyConfig
- the proxy configuration for this clientpublic int getTimeout()
WebConnection
.
The default timeout is 90 seconds.setTimeout(int)
public void setTimeout(int timeout)
Sets the timeout of the WebConnection
. Set to zero for an infinite wait.
Note: The timeout is used twice. The first is for making the socket connection, the second is for data retrieval. If the time is critical you must allow for twice the time specified here.
timeout
- the value of the timeout in millisecondspublic void setSSLInsecureProtocol(String sslInsecureProtocol)
setUseInsecureSSL(boolean)
is set to true
.sslInsecureProtocol
- the SSL protocol for insecure SSL connections,
null
to use for default valuepublic String getSSLInsecureProtocol()
setUseInsecureSSL(boolean)
is set to true
.public void setSSLTrustStore(URL sslTrustStoreUrl, String sslTrustStorePassword, String sslTrustStoreType)
KeyStore
.sslTrustStoreUrl
- the URL which locates the trust storesslTrustStorePassword
- the trust store passwordsslTrustStoreType
- the type of trust store, usually jks
or pkcs12
public KeyStore getSSLTrustStore()
public int getMaxInMemory()
public void setMaxInMemory(int maxInMemory)
maxInMemory
- maximum bytes in memorypublic int getHistorySizeLimit()
pages
kept in WebWindow.getHistory()
.public void setHistorySizeLimit(int historySizeLimit)
getHistoryPageCacheLimit()
to limit the number of page references
stored by the history.historySizeLimit
- maximum number of pages in historypublic int getHistoryPageCacheLimit()
pages
to cache in history.public void setHistoryPageCacheLimit(int historyPageCacheLimit)
pages
to cache in history.
If this value is smaller than the {getHistorySizeLimit()
than
HtmlUnit will only use soft references for the first historyPageCacheLimit
entries in the history. For older entries only the url is saved; the page
will be (re)retrieved on demand.historyPageCacheLimit
- maximum number of pages to cache in history
default is Integer.MAX_VALUE; negative values are having the same effect
as setting this to zero.public InetAddress getLocalAddress()
null
public void setLocalAddress(InetAddress localAddress)
localAddress
- the local addresspublic void setDownloadImages(boolean downloadImages)
downloadImages
- whether to automatically download images by default, or notpublic boolean isDownloadImages()
public void setScreenWidth(int screenWidth)
screenWidth
- the screen widthpublic int getScreenWidth()
public void setScreenHeight(int screenHeight)
screenHeight
- the screen heightpublic int getScreenHeight()
public int getWebSocketMaxTextMessageSize()
public void setWebSocketMaxTextMessageSize(int webSocketMaxTextMessageSize)
webSocketMaxTextMessageSize
- the new valuepublic int getWebSocketMaxTextMessageBufferSize()
public void setWebSocketMaxTextMessageBufferSize(int webSocketMaxTextMessageBufferSize)
webSocketMaxTextMessageBufferSize
- the new valuepublic int getWebSocketMaxBinaryMessageSize()
public void setWebSocketMaxBinaryMessageSize(int webSocketMaxBinaryMessageSize)
webSocketMaxBinaryMessageSize
- the new valuepublic int getWebSocketMaxBinaryMessageBufferSize()
public void setWebSocketMaxBinaryMessageBufferSize(int webSocketMaxBinaryMessageBufferSize)
webSocketMaxBinaryMessageBufferSize
- the new valueCopyright © 2002–2018 Gargoyle Software Inc.. All rights reserved.