com.gargoylesoftware.htmlunit
Class WebClientOptions

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.WebClientOptions
All Implemented Interfaces:
Serializable

public class WebClientOptions
extends Object
implements Serializable

Represents options of a WebClient.

Version:
$Revision: 8931 $
Author:
Ahmed Ashour, Marc Guillemot
See Also:
Serialized Form

Constructor Summary
WebClientOptions()
           
 
Method Summary
 String getHomePage()
          Returns the client's current homepage.
 boolean getPrintContentOnFailingStatusCode()
          Returns true if the content of the resulting document will be printed to the console in the event of a failing response code.
 ProxyConfig getProxyConfig()
          Returns the proxy configuration for this client.
 int getTimeout()
          Gets the timeout value for the WebConnection.
 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 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 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 setGeolocationEnabled(boolean enabled)
          Enables/disables Geolocation support.
 void setHomePage(String homePage)
          Sets the client's homepage.
 void setJavaScriptEnabled(boolean enabled)
          Enables/disables JavaScript support.
 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 setSSLClientCertificate(URL certificateUrl, String certificatePassword, String certificateType)
          Sets the SSL client certificate to use.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebClientOptions

public WebClientOptions()
Method Detail

setUseInsecureSSL

public 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. This is especially useful when you are trying to connect to a server with expired or corrupt certificates.

Parameters:
useInsecureSSL - whether or not to use insecure SSL

isUseInsecureSSL

public boolean isUseInsecureSSL()
Indicates if insecure SSL should be used.

Returns:
true if insecure SSL should be used. Default is false.

setRedirectEnabled

public void setRedirectEnabled(boolean enabled)
Sets whether or not redirections will be followed automatically on receipt of a redirect status code from the server.

Parameters:
enabled - true to enable automatic redirection

isRedirectEnabled

public boolean isRedirectEnabled()
Returns whether or not redirections will be followed automatically on receipt of a redirect status code from the server.

Returns:
true if automatic redirection is enabled

setSSLClientCertificate

public void setSSLClientCertificate(URL certificateUrl,
                                    String certificatePassword,
                                    String certificateType)
Sets the SSL client certificate to use. The needed parameters are used to construct a KeyStore. If the web server requires Renegotiation, you have to set sytem property "sun.security.ssl.allowUnsafeRenegotiation" to true, as hinted in TLS Renegotiation Issue.

Parameters:
certificateUrl - the URL which locates the certificate
certificatePassword - the certificate password
certificateType - the type of certificate, usually "jks" or "pkcs12".

setJavaScriptEnabled

public void setJavaScriptEnabled(boolean enabled)
Enables/disables JavaScript support. By default, this property is enabled.

Parameters:
enabled - true to enable JavaScript support

isJavaScriptEnabled

public boolean isJavaScriptEnabled()
Returns true if JavaScript is enabled and the script engine was loaded successfully.

Returns:
true if JavaScript is enabled

setCssEnabled

public void setCssEnabled(boolean enabled)
Enables/disables CSS support. By default, this property is enabled.

Parameters:
enabled - true to enable CSS support

isCssEnabled

public boolean isCssEnabled()
Returns true if CSS is enabled.

Returns:
true if CSS is enabled

setAppletEnabled

public void setAppletEnabled(boolean enabled)
Enables/disables Applet support. By default, this property is disabled.

Note: as of HtmlUnit-2.4, Applet support is experimental and minimal

Parameters:
enabled - true to enable Applet support
Since:
HtmlUnit-2.4

isAppletEnabled

public boolean isAppletEnabled()
Returns true if Applet are enabled.

Returns:
true if Applet is enabled

setPopupBlockerEnabled

public void setPopupBlockerEnabled(boolean enabled)
Enable/disable the popup window blocker. By default, the popup blocker is disabled, and popup windows are allowed. When set to true, window.open() has no effect and returns null.

Parameters:
enabled - true to enable the popup window blocker

isPopupBlockerEnabled

public boolean isPopupBlockerEnabled()
Returns true if the popup window blocker is enabled.

Returns:
true if the popup window blocker is enabled

setGeolocationEnabled

public void setGeolocationEnabled(boolean enabled)
Enables/disables Geolocation support. By default, this property is disabled.

Parameters:
enabled - true to enable Geolocation support

isGeolocationEnabled

public boolean isGeolocationEnabled()
Returns true if Geolocation is enabled.

Returns:
true if Geolocation is enabled

setDoNotTrackEnabled

public void setDoNotTrackEnabled(boolean enabled)
Enables/disables "Do Not Track" support. By default, this property is disabled.

Parameters:
enabled - true to enable "Do Not Track" support

isDoNotTrackEnabled

public boolean isDoNotTrackEnabled()
Returns true if "Do Not Track" is enabled.

Returns:
true if "Do Not Track" is enabled

setPrintContentOnFailingStatusCode

public 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. Successful response codes are in the range 200-299. The default is true.

Parameters:
enabled - True to enable this feature

getPrintContentOnFailingStatusCode

public boolean getPrintContentOnFailingStatusCode()
Returns true if the content of the resulting document will be printed to the console in the event of a failing response code.

Returns:
true if the content of the resulting document will be printed to the console in the event of a failing response code
See Also:
setPrintContentOnFailingStatusCode(boolean)

setThrowExceptionOnFailingStatusCode

public void setThrowExceptionOnFailingStatusCode(boolean enabled)
Specify whether or not an exception will be thrown in the event of a failing status code. Successful status codes are in the range 200-299. The default is true.

Parameters:
enabled - true to enable this feature

isThrowExceptionOnFailingStatusCode

public boolean isThrowExceptionOnFailingStatusCode()
Returns true if an exception will be thrown in the event of a failing response code.

Returns:
true if an exception will be thrown in the event of a failing response code
See Also:
setThrowExceptionOnFailingStatusCode(boolean)

isThrowExceptionOnScriptError

public 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.

Returns:
true if an exception is thrown on script error (the default)

setThrowExceptionOnScriptError

public void setThrowExceptionOnScriptError(boolean enabled)
Changes the behavior of this webclient when a script error occurs.

Parameters:
enabled - indicates if exception should be thrown or not

setActiveXNative

public void setActiveXNative(boolean allow)
Sets whether to allow native ActiveX or no. Default value is false. Beware that you should never allow running native ActiveX components unless you fully trust the JavaScript code, as it is not controlled by the Java Virtual Machine.

Parameters:
allow - whether to allow or no

isActiveXNative

public boolean isActiveXNative()
Returns whether native ActiveX components are allowed or no.

Returns:
whether native ActiveX components are allowed or no

getHomePage

public String getHomePage()
Returns the client's current homepage.

Returns:
the client's current homepage

setHomePage

public void setHomePage(String homePage)
Sets the client's homepage.

Parameters:
homePage - the new homepage URL

getProxyConfig

public ProxyConfig getProxyConfig()
Returns the proxy configuration for this client.

Returns:
the proxy configuration for this client

setProxyConfig

public void setProxyConfig(ProxyConfig proxyConfig)
Sets the proxy configuration for this client.

Parameters:
proxyConfig - the proxy configuration for this client

getTimeout

public int getTimeout()
Gets the timeout value for the WebConnection. The default timeout is 90 seconds (it was 0 up to HtmlUnit-2.11).

Returns:
the timeout value in milliseconds
See Also:
setTimeout(int)

setTimeout

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.

Parameters:
timeout - the value of the timeout in milliseconds


Copyright © 2002–2014 Gargoyle Software Inc.. All rights reserved.