com.gargoylesoftware.htmlunit
Class WebResponseImpl

java.lang.Object
  extended by com.gargoylesoftware.htmlunit.WebResponseImpl
All Implemented Interfaces:
WebResponse, java.io.Serializable
Direct Known Subclasses:
StringWebResponse

public class WebResponseImpl
extends java.lang.Object
implements WebResponse, java.io.Serializable

Simple base class for WebResponse.

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

Constructor Summary
WebResponseImpl(WebResponseData responseData, java.lang.String charset, java.net.URL url, SubmitMethod requestMethod, long loadTime)
 Construct with all data
WebResponseImpl(WebResponseData responseData, java.net.URL url, SubmitMethod requestMethod, long loadTime)
 Construct with all data
 
Method Summary
 java.io.InputStream getContentAsStream()
 Return the content from the server as an input stream
 java.lang.String getContentAsString()
 Return the content from the server as a string
 java.lang.String getContentCharSet()
 Return the content charset value. If no charset is specified in headers, then try to guess it from the content.
 java.lang.String getContentType()
 Return the content type returned from the server.
 long getLoadTimeInMilliSeconds()
 Return the time it took to load this web response in milliseconds.
 SubmitMethod getRequestMethod()
 Return the method used for the request resulting into this response.
 byte[] getResponseBody()
 Return the response body as byte array.
 java.util.List getResponseHeaders()
 Return the response headers as a List of NameValuePairs.
 java.lang.String getResponseHeaderValue(java.lang.String headerName)
 Return the value of the specified header from this response.
 int getStatusCode()
 Return the status code that was returned by the server
 java.lang.String getStatusMessage()
 Return the status message that was returned from the server
 java.net.URL getUrl()
 Return the URL that was used to load this page.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebResponseImpl

public WebResponseImpl(WebResponseData responseData,
                       java.lang.String charset,
                       java.net.URL url,
                       SubmitMethod requestMethod,
                       long loadTime)
Construct with all data

Parameters:
responseData - Data that was send back
charset - Charset used if not returned in the response.
url - Where this response came from
requestMethod - The method used to get this response
loadTime - How long the response took to be sent

WebResponseImpl

public WebResponseImpl(WebResponseData responseData,
                       java.net.URL url,
                       SubmitMethod requestMethod,
                       long loadTime)
Construct 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
Method Detail

getContentAsStream

public java.io.InputStream getContentAsStream()
                                       throws java.io.IOException
Return the content from the server as an input stream

Specified by:
getContentAsStream in interface WebResponse
Returns:
See above
Throws:
java.io.IOException - If an IO problem occurs

getContentAsString

public java.lang.String getContentAsString()
Return the content from the server as a string

Specified by:
getContentAsString in interface WebResponse
Returns:
See above

getContentCharSet

public java.lang.String getContentCharSet()
Return the content charset value. If no charset is specified in headers, then try to guess it from the content. Currently only UTF-8 with BOM marker is detected this way.

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

getContentType

public java.lang.String getContentType()
Return the content type returned from the server. Ie "text/html"

Specified by:
getContentType in interface WebResponse
Returns:
See above

getLoadTimeInMilliSeconds

public long getLoadTimeInMilliSeconds()
Return the time it took to load this web response in milliseconds.

Specified by:
getLoadTimeInMilliSeconds in interface WebResponse
Returns:
The load time.

getRequestMethod

public SubmitMethod getRequestMethod()
Return the method used for the request resulting into this response.

Specified by:
getRequestMethod in interface WebResponse
Returns:
the method

getResponseBody

public byte[] getResponseBody()
Return the response body as byte array.

Specified by:
getResponseBody in interface WebResponse
Returns:
response body.

getResponseHeaders

public java.util.List getResponseHeaders()
Return the response headers as a List of NameValuePairs.

Specified by:
getResponseHeaders in interface WebResponse
Returns:
a List of NameValuePairs.

getResponseHeaderValue

public java.lang.String getResponseHeaderValue(java.lang.String headerName)
Return the value of the specified header from this response.

Specified by:
getResponseHeaderValue in interface WebResponse
Parameters:
headerName - The name of the header
Returns:
The value of the specified header

getStatusCode

public int getStatusCode()
Return the status code that was returned by the server

Specified by:
getStatusCode in interface WebResponse
Returns:
See above.

getStatusMessage

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

Specified by:
getStatusMessage in interface WebResponse
Returns:
See above

getUrl

public java.net.URL getUrl()
Return the URL that was used to load this page.

Specified by:
getUrl in interface WebResponse
Returns:
The originating URL


Copyright © 2003-2009 AppPerfect Corporation. All Rights Reserved.