public class WebClientOptions extends Object implements Serializable
WebClient instances.
This class provides fine-grained control over client behavior including:
All options have sensible defaults and can be modified independently.
| Modifier and Type | Class and Description |
|---|---|
static class |
WebClientOptions.Geolocation
Support class for Geolocation.
|
| Constructor and Description |
|---|
WebClientOptions() |
| Modifier and Type | Method and Description |
|---|---|
long |
getConnectionTimeToLive()
Gets the connTimeToLive value for the HttpClient connection pool.
|
WebClientOptions.Geolocation |
getGeolocation() |
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 stored in memory before content is saved to temporary files.
|
int |
getNekoReaderBufferSize()
Returns the Neko HTML parser reader buffer size.
|
int |
getPageRefreshLimit()
Returns the limit to be used when a page refreshes itself by using a
http refresh header or meta tag.
|
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.
|
SSLContext |
getSSLContext()
Gets the SSLContext; if this is set this is used and some other settings are ignored
(protocol, keyStore, keyStorePassword, trustStore, sslClientCertificateStore, sslClientCertificatePassword).
|
String |
getSSLInsecureProtocol()
Gets the SSL protocol, to be used only when
setUseInsecureSSL(boolean) is set to true. |
KeyStore |
getSSLTrustStore()
Gets the SSL TrustStore.
|
File |
getTempFileDirectory()
Returns the directory to be used for storing the response content in
a temporary file see
getMaxInMemory(). |
int |
getTimeout()
Gets the timeout value for the
WebConnection. |
int |
getWebSocketMaxBinaryMessageBufferSize()
Returns the maximum buffer size in bytes for assembling WebSocket binary messages.
|
int |
getWebSocketMaxBinaryMessageSize()
Returns the maximum size in bytes for WebSocket binary messages.
|
int |
getWebSocketMaxTextMessageBufferSize()
Returns the maximum buffer size in bytes for assembling WebSocket text messages.
|
int |
getWebSocketMaxTextMessageSize()
Returns the maximum size in bytes for WebSocket text messages.
|
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 |
isFetchPolyfillEnabled() |
boolean |
isFileProtocolForXMLHttpRequestsAllowed()
Indicates if the client will accept XMLHttpRequests to URL's
using the 'file' protocol.
|
boolean |
isGeolocationEnabled() |
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.
|
boolean |
isWebSocketEnabled()
Returns
true if WebSockets are enabled. |
void |
setConnectionTimeToLive(long connectionTimeToLive)
Sets the connection time-to-live for the HttpClient connection pool.
|
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 |
setFetchPolyfillEnabled(boolean enabled)
Sets whether or not fetch polyfill should be used.
|
void |
setFileProtocolForXMLHttpRequestsAllowed(boolean fileProtocolForXMLHttpRequestsAllowed)
If set to
true, the client will accept XMLHttpRequests to URL's
using the 'file' protocol. |
void |
setGeolocation(WebClientOptions.Geolocation geolocation)
Sets the
WebClientOptions.Geolocation to be used. |
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 network interface address for outgoing HTTP requests.
|
void |
setMaxInMemory(int maxInMemory)
Sets the maximum bytes to have in memory, after which the content is saved to a temporary file.
|
void |
setNekoReaderBufferSize(int nekoReaderBufferSize)
Sets the Neko HTML parser reader buffer size.
|
void |
setPageRefreshLimit(int pageRefreshLimit)
Sets the redirect limit for page refresh operations using HTTP refresh headers or meta tags.
|
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 |
setSSLClientCertificateKeyStore(InputStream keyStoreInputStream,
String keyStorePassword,
String keyStoreType)
Sets the SSL client certificate
KeyStore to use. |
void |
setSSLClientCertificateKeyStore(KeyStore keyStore,
char[] keyStorePassword)
Sets the SSL client certificate
KeyStore to use. |
void |
setSSLClientCertificateKeyStore(URL keyStoreUrl,
String keyStorePassword,
String keyStoreType)
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 |
setSSLContext(SSLContext sslContext)
Sets the SSLContext; if this is set it is used and some other settings are ignored
(protocol, keyStore, keyStorePassword, trustStore, sslClientCertificateStore, sslClientCertificatePassword).
|
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 |
setTempFileDirectory(File tempFileDirectory)
Sets the directory to be used for storing response content in temporary files.
|
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 |
setWebSocketEnabled(boolean enabled)
Enables/disables WebSocket support.
|
void |
setWebSocketMaxBinaryMessageBufferSize(int webSocketMaxBinaryMessageBufferSize)
Sets the maximum buffer size in bytes for assembling WebSocket binary messages.
|
void |
setWebSocketMaxBinaryMessageSize(int webSocketMaxBinaryMessageSize)
Sets the maximum size in bytes for WebSocket binary messages.
|
void |
setWebSocketMaxTextMessageBufferSize(int webSocketMaxTextMessageBufferSize)
Sets the maximum buffer size in bytes for assembling WebSocket text messages.
|
void |
setWebSocketMaxTextMessageSize(int webSocketMaxTextMessageSize)
Sets the maximum size in bytes for WebSocket text messages.
|
public void setSSLContext(SSLContext sslContext)
This property is transient (because SSLContext is not serializable)
sslContext - the SSLContext, null to use for default valuepublic SSLContext getSSLContext()
This property is transient (because SSLContext is not serializable)
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 void setPageRefreshLimit(int pageRefreshLimit)
Note: The NiceRefreshHandler and ImmediateRefreshHandler
have additional loop protection that may trigger before this limit.
pageRefreshLimit - the maximum number of refresh loops, or -1 for unlimitedpublic File getTempFileDirectory()
getMaxInMemory().public void setTempFileDirectory(File tempFileDirectory) throws IOException
setMaxInMemory(int) for when temporary files are created.
If the directory doesn't exist, it will be created automatically.tempFileDirectory - the directory to use, or null for system defaultIOException - if directory creation fails