## com.gargoylesoftware.htmlunit
Class WebResponseImpl

    java.lang.Object
      com.gargoylesoftware.htmlunit.WebResponseImpl

All Implemented Interfaces:
  WebResponse, java.io.Serializable

Direct Known Subclasses:
  StringWebResponse

    public class WebResponseImpl

extends java.lang.Object
implements WebResponse

Simple base class for `WebResponse`.

Version:
  $Revision: 4872 $
Author:
  Brad Clarke, Ahmed Ashour
See Also:
  Serialized Form

Constructor Summary
`WebResponseImpl(WebResponseData responseData, java.lang.String charset, WebRequestSettings requestSettings, long loadTime)` Deprecated. As of 2.6, please use @link `WebResponseImpl(WebResponseData, WebRequestSettings, long)`
`WebResponseImpl(WebResponseData responseData, java.net.URL url, HttpMethod requestMethod, long loadTime)` Constructs with all data.
`WebResponseImpl(WebResponseData responseData, WebRequestSettings requestSettings, long loadTime)` Constructs with all data.

Method Summary
`byte[]` `getContentAsBytes()` Returns the response content as a byte array.
`java.io.InputStream` `getContentAsStream()` Returns the response content as an input stream.
`java.lang.String` `getContentAsString()` Returns the response content as a string, using the charset/encoding specified in the server response.
`java.lang.String` `getContentAsString(java.lang.String encoding)` Returns the response content as a string, using the specified charset/encoding, rather than the charset/encoding specified in the server response.
`java.lang.String` `getContentCharset()` Returns the content charset for this response, even if no charset was specified explicitly.
`java.lang.String` `getContentCharSet()` Deprecated. As of 2.6, please use @link `getContentCharset()`
`java.lang.String` `getContentCharsetOrNull()` Returns the content charset specified explicitly in the header or in the content, or `null` if none was specified.
`java.lang.String` `getContentType()` Returns the content type returned from the server, e.g.
`long` `getLoadTime()` Returns the time it took to load this web response, in milliseconds.
`HttpMethod` `getRequestMethod()` Deprecated. As of 2.6, please use `getRequestSettings()`.getHttpMethod()
`WebRequestSettings` `getRequestSettings()` Returns the request settings used to load this response.
`java.net.URL` `getRequestUrl()` Deprecated. As of 2.6, please use `getRequestSettings()`.getUrl()
`java.util.List<org.apache.commons.httpclient.NameValuePair>` `getResponseHeaders()` Returns the response headers as a list of `NameValuePair`s.
`java.lang.String` `getResponseHeaderValue(java.lang.String headerName)` Returns the value of the specified response header.
`int` `getStatusCode()` Returns the status code that was returned by the server.
`java.lang.String` `getStatusMessage()` Returns the status message that was returned from the server.
`java.net.URL` `getUrl()` Synonym for `WebResponse.getRequestUrl()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WebResponseImpl

    public WebResponseImpl(WebResponseData responseData,
                           java.net.URL url,
                           HttpMethod requestMethod,
                           long loadTime)

  Constructs with all data.

  Parameters:
    `responseData` - Data that was send back
    `url` - Where this response came from
    `requestMethod` - the method used to get this response
    `loadTime` - How long the response took to be sent

### WebResponseImpl

    @Deprecated
    public WebResponseImpl(WebResponseData responseData,
                                      java.lang.String charset,
                                      WebRequestSettings requestSettings,
                                      long loadTime)

  Deprecated. As of 2.6, please use @link `WebResponseImpl(WebResponseData, WebRequestSettings, long)`

  Constructs with all data.

  Parameters:
    `responseData` - Data that was send back
    `charset` - Charset used if not returned in the response
    `requestSettings` - the request settings used to get this response
    `loadTime` - How long the response took to be sent

### WebResponseImpl

    public WebResponseImpl(WebResponseData responseData,
                           WebRequestSettings requestSettings,
                           long loadTime)

  Constructs with all data.

  Parameters:
    `responseData` - Data that was send back
    `requestSettings` - the request settings used to get this response
    `loadTime` - How long the response took to be sent

Method Detail

### getRequestSettings

    public WebRequestSettings getRequestSettings()

  Returns the request settings used to load this response.

  Specified by:
    `getRequestSettings` in interface `WebResponse`
  Returns:
    the request settings used to load this response

### getRequestMethod

    @Deprecated
    public HttpMethod getRequestMethod()

  Deprecated. As of 2.6, please use `getRequestSettings()`.getHttpMethod()

  Returns the method used for the request resulting in this response.

  Specified by:
    `getRequestMethod` in interface `WebResponse`
  Returns:
    the method used for the request resulting in this response

### getRequestUrl

    @Deprecated
    public java.net.URL getRequestUrl()

  Deprecated. As of 2.6, please use `getRequestSettings()`.getUrl()

  Returns the URL that was used to load this page.

  Specified by:
    `getRequestUrl` in interface `WebResponse`
  Returns:
    the URL that was used to load this page

### getUrl

    public java.net.URL getUrl()

  Description copied from interface: `WebResponse`
  Synonym for `WebResponse.getRequestUrl()`

  Specified by:
    `getUrl` in interface `WebResponse`

### getResponseHeaders

    public java.util.List<org.apache.commons.httpclient.NameValuePair> getResponseHeaders()

  Returns the response headers as a list of `NameValuePair`s.

  Specified by:
    `getResponseHeaders` in interface `WebResponse`
  Returns:
    the response headers as a list of `NameValuePair`s

### getResponseHeaderValue

    public java.lang.String getResponseHeaderValue(java.lang.String headerName)

  Returns the value of the specified response header.

  Specified by:
    `getResponseHeaderValue` in interface `WebResponse`
  Parameters:
    `headerName` - the name of the header whose value is to be returned
  Returns:
    the value of the specified response header

### getStatusCode

    public int getStatusCode()

  Returns the status code that was returned by the server.

  Specified by:
    `getStatusCode` in interface `WebResponse`
  Returns:
    the status code that was returned by the server

### getStatusMessage

    public java.lang.String getStatusMessage()

  Returns the status message that was returned from the server.

  Specified by:
    `getStatusMessage` in interface `WebResponse`
  Returns:
    the status message that was returned from the server

### getContentType

    public java.lang.String getContentType()

  Returns the content type returned from the server, e.g. "text/html".

  Specified by:
    `getContentType` in interface `WebResponse`
  Returns:
    the content type returned from the server, e.g. "text/html"

### getContentCharSet

    @Deprecated
    public java.lang.String getContentCharSet()

  Deprecated. As of 2.6, please use @link `getContentCharset()`

  Returns the content charset; may be `null`. If no charset is specified in headers, then try to guess it from the content.

  Specified by:
    `getContentCharSet` in interface `WebResponse`
  Returns:
    the charset, `TextUtil.DEFAULT_CHARSET` if it can't be determined
  See Also:
    Wikipedia - Byte Order Mark

### getContentCharsetOrNull

    public java.lang.String getContentCharsetOrNull()

  Returns the content charset specified explicitly in the header or in the content, or `null` if none was specified.

  Specified by:
    `getContentCharsetOrNull` in interface `WebResponse`
  Returns:
    the content charset specified explicitly in the header or in the content, or `null` if none was specified

### getContentCharset

    public java.lang.String getContentCharset()

  Returns the content charset for this response, even if no charset was specified explicitly. This method always returns a valid charset. This method first checks the "Content-Type" header; if not found, it checks the response content; as a last resort, this method returns `TextUtil.DEFAULT_CHARSET`.

  Specified by:
    `getContentCharset` in interface `WebResponse`
  Returns:
    the content charset for this response

### getContentAsString

    public java.lang.String getContentAsString()

  Returns the response content as a string, using the charset/encoding specified in the server response.

  Specified by:
    `getContentAsString` in interface `WebResponse`
  Returns:
    the response content as a string, using the charset/encoding specified in the server response

### getContentAsString

    public java.lang.String getContentAsString(java.lang.String encoding)

  Returns the response content as a string, using the specified charset/encoding, rather than the charset/encoding specified in the server response. If the specified charset/encoding is not supported then the default system encoding is used.

  Specified by:
    `getContentAsString` in interface `WebResponse`
  Parameters:
    `encoding` - the charset/encoding to use to convert the response content into a string
  Returns:
    the response content as a string

### getContentAsStream

    public java.io.InputStream getContentAsStream()
                                           throws java.io.IOException

  Returns the response content as an input stream.

  Specified by:
    `getContentAsStream` in interface `WebResponse`
  Returns:
    the response content as an input stream
  Throws:
    `java.io.IOException` - if an IO problem occurs

### getContentAsBytes

    public byte[] getContentAsBytes()

  Returns the response content as a byte array.

  Specified by:
    `getContentAsBytes` in interface `WebResponse`
  Returns:
    the response content as a byte array

### getLoadTime

    public long getLoadTime()

  Returns the time it took to load this web response, in milliseconds.

  Specified by:
    `getLoadTime` in interface `WebResponse`
  Returns:
    the time it took to load this web response, in milliseconds

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