com.gargoylesoftware.htmlunit
Class WebRequestSettings

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

public class WebRequestSettings
extends Object
implements Serializable

Parameter object for making web requests.

Version:
$Revision: 4162 $
Author:
Brad Clarke, Hans Donner, Ahmed Ashour
See Also:
Serialized Form

Constructor Summary
WebRequestSettings(URL url)
          Instantiates a WebRequestSettings for the specified URL.
WebRequestSettings(URL url, HttpMethod submitMethod)
          Instantiates a WebRequestSettings for the specified URL using the specified HTTP submit method.
WebRequestSettings(WebRequestSettings originalRequest, URL url)
          Instantiates a WebRequestSettings for the specified URL using the proxy configuration from the specified original request.
 
Method Summary
 void addAdditionalHeader(String name, String value)
          Adds the specified name/value pair to the additional HTTP headers.
 Map<String,String> getAdditionalHeaders()
          Returns the additional HTTP headers to use.
 String getCharset()
          Returns the character set to use to perform the request.
 CredentialsProvider getCredentialsProvider()
          Returns the credentials provider to use.
 FormEncodingType getEncodingType()
          Returns the form encoding type to use.
 HttpMethod getHttpMethod()
          Returns the HTTP submit method to use.
 String getProxyHost()
          Returns the proxy host to use.
 int getProxyPort()
          Returns the proxy port to use.
 String getRequestBody()
          Returns the body content to be submitted if this is a POST request.
 List<NameValuePair> getRequestParameters()
          Retrieves the request parameters to use.
 URL getUrl()
          Returns the target URL.
 void setAdditionalHeaders(Map<String,String> additionalHeaders)
          Sets the additional HTTP headers to use.
 void setCharset(String charset)
          Sets the character set to use to perform the request.
 void setCredentialsProvider(CredentialsProvider credentialsProvider)
          Sets the credentials provider to use.
 void setEncodingType(FormEncodingType encodingType)
          Sets the form encoding type to use.
 void setHttpMethod(HttpMethod submitMethod)
          Sets the HTTP submit method to use.
 void setProxyHost(String proxyHost)
          Sets the proxy host to use.
 void setProxyPort(int proxyPort)
          Sets the proxy port to use.
 void setRequestBody(String requestBody)
          Sets the body content to be submitted if this is a POST request.
 void setRequestParameters(List<NameValuePair> requestParameters)
          Sets the request parameters to use.
 void setUrl(URL url)
          Sets the target URL.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebRequestSettings

public WebRequestSettings(URL url)
Instantiates a WebRequestSettings for the specified URL.

Parameters:
url - the target URL

WebRequestSettings

public WebRequestSettings(WebRequestSettings originalRequest,
                          URL url)
Instantiates a WebRequestSettings for the specified URL using the proxy configuration from the specified original request.

Parameters:
originalRequest - the original request
url - the target URL

WebRequestSettings

public WebRequestSettings(URL url,
                          HttpMethod submitMethod)
Instantiates a WebRequestSettings for the specified URL using the specified HTTP submit method.

Parameters:
url - the target URL
submitMethod - the HTTP submit method to use
Method Detail

getUrl

public URL getUrl()
Returns the target URL.

Returns:
the target URL

setUrl

public void setUrl(URL url)
Sets the target URL.

Parameters:
url - the target URL

getProxyHost

public String getProxyHost()
Returns the proxy host to use.

Returns:
the proxy host to use

setProxyHost

public void setProxyHost(String proxyHost)
Sets the proxy host to use.

Parameters:
proxyHost - the proxy host to use

getProxyPort

public int getProxyPort()
Returns the proxy port to use.

Returns:
the proxy port to use

setProxyPort

public void setProxyPort(int proxyPort)
Sets the proxy port to use.

Parameters:
proxyPort - the proxy port to use

getEncodingType

public FormEncodingType getEncodingType()
Returns the form encoding type to use.

Returns:
the form encoding type to use

setEncodingType

public void setEncodingType(FormEncodingType encodingType)
Sets the form encoding type to use.

Parameters:
encodingType - the form encoding type to use

getRequestParameters

public List<NameValuePair> getRequestParameters()
Retrieves the request parameters to use. If set, these request parameters will overwrite any request parameters which may be present in the URL. Should not be used in combination with the request body.

Returns:
the request parameters to use

setRequestParameters

public void setRequestParameters(List<NameValuePair> requestParameters)
                          throws RuntimeException
Sets the request parameters to use. If set, these request parameters will overwrite any request parameters which may be present in the URL. Should not be used in combination with the request body.

Parameters:
requestParameters - the request parameters to use
Throws:
RuntimeException - if the request body has already been set

getRequestBody

public String getRequestBody()
Returns the body content to be submitted if this is a POST request. Ignored for all other request types. Should not be used in combination with request parameters.

Returns:
the body content to be submitted if this is a POST request

setRequestBody

public void setRequestBody(String requestBody)
                    throws RuntimeException
Sets the body content to be submitted if this is a POST request. Ignored for all other request types. Should not be used in combination with request parameters.

Parameters:
requestBody - the body content to be submitted if this is a POST request
Throws:
RuntimeException - if the request parameters have already been set or this is not a POST request

getHttpMethod

public HttpMethod getHttpMethod()
Returns the HTTP submit method to use.

Returns:
the HTTP submit method to use

setHttpMethod

public void setHttpMethod(HttpMethod submitMethod)
Sets the HTTP submit method to use.

Parameters:
submitMethod - the HTTP submit method to use

getAdditionalHeaders

public Map<String,String> getAdditionalHeaders()
Returns the additional HTTP headers to use.

Returns:
the additional HTTP headers to use

setAdditionalHeaders

public void setAdditionalHeaders(Map<String,String> additionalHeaders)
Sets the additional HTTP headers to use.

Parameters:
additionalHeaders - the additional HTTP headers to use

addAdditionalHeader

public void addAdditionalHeader(String name,
                                String value)
Adds the specified name/value pair to the additional HTTP headers.

Parameters:
name - the name of the additional HTTP header
value - the value of the additional HTTP header

getCredentialsProvider

public CredentialsProvider getCredentialsProvider()
Returns the credentials provider to use.

Returns:
the credentials provider to use

setCredentialsProvider

public void setCredentialsProvider(CredentialsProvider credentialsProvider)
Sets the credentials provider to use.

Parameters:
credentialsProvider - the credentials provider to use

getCharset

public String getCharset()
Returns the character set to use to perform the request.

Returns:
the character set to use to perform the request

setCharset

public void setCharset(String charset)
Sets the character set to use to perform the request. The default value is TextUtil.DEFAULT_CHARSET.

Parameters:
charset - the character set to use to perform the request

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a string representation of this object


Copyright © 2002-2009 Gargoyle Software Inc.. All Rights Reserved.