public class WebClientOptions extends Object implements Serializable
WebClient
.Modifier and Type | Class and Description |
---|---|
static class |
WebClientOptions.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 to have in memory, after which the content is saved to a temporary file.
|
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() |
int |
getWebSocketMaxBinaryMessageSize() |
int |
getWebSocketMaxTextMessageBufferSize() |
int |
getWebSocketMaxTextMessageSize() |
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 connTimeToLive of 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 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 temporary 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 |
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 the response content in
a temporary file see
setMaxInMemory(int) . |
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 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 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 File getTempFileDirectory()
getMaxInMemory()
.public void setTempFileDirectory(File tempFileDirectory) throws IOException
setMaxInMemory(int)
.
If the given directory does not exist, this creates it.tempFileDirectory
- the directory to be used or null to use the system defaultIOException
- in case of errorpublic boolean isRedirectEnabled()
public void setSSLClientCertificateKeyStore(KeyStore keyStore, char[] keyStorePassword)
KeyStore
to use.
If the web server requires Renegotiation, you have to set system property "sun.security.ssl.allowUnsafeRenegotiation" to true, as hinted in TLS Renegotiation Issue.
In some cases the impl seems to pick old certificates from the KeyStore
. To avoid
that, wrap your KeyStore
inside your own KeyStore
impl and filter out outdated
certificates.
keyStore
- KeyStore
to usekeyStorePassword
- the keystore passwordpublic void setSSLClientCertificateKeyStore(URL keyStoreUrl, String keyStorePassword, String keyStoreType)
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.
public void setSSLClientCertificateKeyStore(InputStream keyStoreInputStream, String keyStorePassword, String keyStoreType)
KeyStore
to use. The parameters are used to
construct the 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.
In some cases the impl seems to pick old certificates from the KeyStore
. To avoid
that, wrap your KeyStore
inside your own KeyStore
impl and filter out outdated
certificates. Provide the KeyStore
to the options instead of the input stream.
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 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 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 featurepublic 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 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 long getConnectionTimeToLive()
public void setConnectionTimeToLive(long connectionTimeToLive)
connectionTimeToLive
- 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)
The needed parameters are used to construct a 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)
setHistoryPageCacheLimit(int)
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()
On machines with multiple network interfaces, this parameter can be used to select the network interface from which the connection originates.
Default: null
public void setLocalAddress(InetAddress localAddress)
On machines with multiple network interfaces, this parameter can be used to select the network interface from which the connection originates.
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 void setWebSocketEnabled(boolean enabled)
enabled
- true
to enable WebSocket supportpublic boolean isWebSocketEnabled()
true
if WebSockets are enabled.true
if WebSockets are enabledpublic 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 valuepublic void setFetchPolyfillEnabled(boolean enabled)
enabled
- true to enable fetch polyfillpublic boolean isFetchPolyfillEnabled()
public void setGeolocationEnabled(boolean enabled)
enabled
- true
to enable Geolocation supportpublic boolean isGeolocationEnabled()
true
if Geolocation is enabledpublic WebClientOptions.Geolocation getGeolocation()
WebClientOptions.Geolocation
public void setGeolocation(WebClientOptions.Geolocation geolocation)
WebClientOptions.Geolocation
to be used.geolocation
- the new location or nullpublic void setFileProtocolForXMLHttpRequestsAllowed(boolean fileProtocolForXMLHttpRequestsAllowed)
true
, the client will accept XMLHttpRequests to URL's
using the 'file' protocol. Allowing this introduces security problems and is
therefore not allowed by current browsers. But some browsers have special settings
to open this door; therefore we have this option.fileProtocolForXMLHttpRequestsAllowed
- whether or not allow (local) file accesspublic boolean isFileProtocolForXMLHttpRequestsAllowed()
true
if access to local files is allowed.Copyright © 2002–2024 Gargoyle Software Inc.. All rights reserved.