com.gargoylesoftware.htmlunit
Class WebRequestSettings

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

public class WebRequestSettings
extends java.lang.Object
implements java.io.Serializable

Parameter object for making web requests.

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

Constructor Summary
WebRequestSettings(java.net.URL url)
          Instantiates a WebRequestSettings for the specified URL.
WebRequestSettings(java.net.URL url, HttpMethod submitMethod)
          Instantiates a WebRequestSettings for the specified URL using the specified HTTP submit method.
WebRequestSettings(WebRequestSettings originalRequest, java.net.URL url)
          Instantiates a WebRequestSettings for the specified URL using the proxy configuration from the specified original request.
 
Method Summary
 void addAdditionalHeader(java.lang.String name, java.lang.String value)
          Deprecated. As of 2.6, please use setAdditionalHeader(String, String) instead
 java.util.Map<java.lang.String,java.lang.String> getAdditionalHeaders()
          Returns the additional HTTP headers to use.
 java.lang.String getCharset()
          Returns the character set to use to perform the request.
 org.apache.commons.httpclient.auth.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.
 java.lang.String getProxyHost()
          Returns the proxy host to use.
 int getProxyPort()
          Returns the proxy port to use.
 java.lang.String getRequestBody()
          Returns the body content to be submitted if this is a POST request.
 java.util.List<org.apache.commons.httpclient.NameValuePair> getRequestParameters()
          Retrieves the request parameters to use.
 java.net.URL getUrl()
          Returns the target URL.
 void removeAdditionalHeader(java.lang.String name)
          Removed the specified name/value pair from the additional HTTP headers.
 void setAdditionalHeader(java.lang.String name, java.lang.String value)
          Sets the specified name/value pair in the additional HTTP headers.
 void setAdditionalHeaders(java.util.Map<java.lang.String,java.lang.String> additionalHeaders)
          Sets the additional HTTP headers to use.
 void setCharset(java.lang.String charset)
          Sets the character set to use to perform the request.
 void setCredentialsProvider(org.apache.commons.httpclient.auth.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(java.lang.String proxyHost)
          Sets the proxy host to use.
 void setProxyPort(int proxyPort)
          Sets the proxy port to use.
 void setRequestBody(java.lang.String requestBody)
          Sets the body content to be submitted if this is a POST request.
 void setRequestParameters(java.util.List<org.apache.commons.httpclient.NameValuePair> requestParameters)
          Sets the request parameters to use.
 void setUrl(java.net.URL url)
          Sets the target URL.
 java.lang.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(java.net.URL url)
Instantiates a WebRequestSettings for the specified URL.

Parameters:
url - the target URL

WebRequestSettings

public WebRequestSettings(WebRequestSettings originalRequest,
                          java.net.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(java.net.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 java.net.URL getUrl()
Returns the target URL.

Returns:
the target URL

setUrl

public void setUrl(java.net.URL url)
Sets the target URL. The URL may be simplified if needed (for instance eliminating irrelevant path portions like "/./").

Parameters:
url - the target URL

getProxyHost

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

Returns:
the proxy host to use

setProxyHost

public void setProxyHost(java.lang.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 java.util.List<org.apache.commons.httpclient.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(java.util.List<org.apache.commons.httpclient.NameValuePair> requestParameters)
                          throws java.lang.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:
java.lang.RuntimeException - if the request body has already been set

getRequestBody

public java.lang.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(java.lang.String requestBody)
                    throws java.lang.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:
java.lang.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 java.util.Map<java.lang.String,java.lang.String> getAdditionalHeaders()
Returns the additional HTTP headers to use.

Returns:
the additional HTTP headers to use

setAdditionalHeaders

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

Parameters:
additionalHeaders - the additional HTTP headers to use

setAdditionalHeader

public void setAdditionalHeader(java.lang.String name,
                                java.lang.String value)
Sets the specified name/value pair in the additional HTTP headers.

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

addAdditionalHeader

@Deprecated
public void addAdditionalHeader(java.lang.String name,
                                           java.lang.String value)
Deprecated. As of 2.6, please use setAdditionalHeader(String, String) instead

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

removeAdditionalHeader

public void removeAdditionalHeader(java.lang.String name)
Removed the specified name/value pair from the additional HTTP headers.

Parameters:
name - the name of the additional HTTP header

getCredentialsProvider

public org.apache.commons.httpclient.auth.CredentialsProvider getCredentialsProvider()
Returns the credentials provider to use.

Returns:
the credentials provider to use

setCredentialsProvider

public void setCredentialsProvider(org.apache.commons.httpclient.auth.CredentialsProvider credentialsProvider)
Sets the credentials provider to use.

Parameters:
credentialsProvider - the credentials provider to use

getCharset

public java.lang.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(java.lang.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 java.lang.String toString()
Returns a string representation of this object.

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


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