com.gargoylesoftware.htmlunit
Interface WebResponse

All Superinterfaces:
java.io.Serializable
All Known Implementing Classes:
StringWebResponse, WebResponseImpl, WebResponseWrapper

public interface WebResponse
extends java.io.Serializable

A response from a web server.

Version:
$Revision: 4872 $
Author:
Mike Bowler, Noboru Sinohara, Marc Guillemot, Ahmed Ashour

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 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 NameValuePairs.
 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 getRequestUrl()
 

Method Detail

getRequestSettings

WebRequestSettings getRequestSettings()
Returns the request settings used to load this response.

Returns:
the request settings used to load this response

getRequestMethod

@Deprecated
HttpMethod getRequestMethod()
Deprecated. as of 2.6, please use getRequestSettings().getHttpMethod()

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

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

getRequestUrl

@Deprecated
java.net.URL getRequestUrl()
Deprecated. as of 2.6, please use getRequestSettings().getUrl()

Returns the URL that was used to load this page.

Returns:
the URL that was used to load this page

getUrl

java.net.URL getUrl()
Synonym for getRequestUrl()


getResponseHeaders

java.util.List<org.apache.commons.httpclient.NameValuePair> getResponseHeaders()
Returns the response headers as a list of NameValuePairs.

Returns:
the response headers as a list of NameValuePairs

getResponseHeaderValue

java.lang.String getResponseHeaderValue(java.lang.String headerName)
Returns the value of the specified response header.

Parameters:
headerName - the name of the header whose value is to be returned
Returns:
the value of the specified response header

getStatusCode

int getStatusCode()
Returns the status code that was returned by the server.

Returns:
the status code that was returned by the server

getStatusMessage

java.lang.String getStatusMessage()
Returns the status message that was returned from the server.

Returns:
the status message that was returned from the server

getContentType

java.lang.String getContentType()
Returns the content type returned from the server, e.g. "text/html".

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

getContentCharSet

@Deprecated
java.lang.String getContentCharSet()
Deprecated. as of 2.6, please use getContentCharset()

Returns the content charset; may be null.

Returns:
the content charset

getContentCharsetOrNull

java.lang.String getContentCharsetOrNull()
Returns the content charset specified explicitly in the header or in the content, or null if none was specified.

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

getContentCharset

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.

Returns:
the content charset for this response

getContentAsString

java.lang.String getContentAsString()
Returns the response content as a string, using the charset/encoding specified in the server response.

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

getContentAsString

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.

Parameters:
encoding - the charset/encoding to use to convert the response content into a string
Returns:
the response content as a string

getContentAsStream

java.io.InputStream getContentAsStream()
                                       throws java.io.IOException
Returns the response content as an input stream.

Returns:
the response content as an input stream
Throws:
java.io.IOException - if an IO problem occurs

getContentAsBytes

byte[] getContentAsBytes()
Returns the response content as a byte array.

Returns:
the response content as a byte array

getLoadTime

long getLoadTime()
Returns the time it took to load this web response, in milliseconds.

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


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