com.gargoylesoftware.htmlunit
Class WebResponseData

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

public class WebResponseData
extends Object
implements Serializable

Simple data object to simplify WebResponse creation.

Version:
$Revision: 7619 $
Author:
Brad Clarke, Daniel Gredler, Ahmed Ashour, Ronald Brill
See Also:
Serialized Form

Constructor Summary
  WebResponseData(byte[] body, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Constructs with a raw byte[] (mostly for testing).
  WebResponseData(DownloadedContent responseBody, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Constructor.
protected WebResponseData(int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Constructs without data stream for subclasses that override getBody().
 
Method Summary
 void cleanUp()
          Clean up the downloaded content.
 byte[] getBody()
          Returns the response body.
 InputStream getInputStream()
          Returns a new InputStream allowing to read the downloaded content.
 List<NameValuePair> getResponseHeaders()
           
 int getStatusCode()
           
 String getStatusMessage()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebResponseData

public WebResponseData(byte[] body,
                       int statusCode,
                       String statusMessage,
                       List<NameValuePair> responseHeaders)
Constructs with a raw byte[] (mostly for testing).

Parameters:
body - Body of this response
statusCode - Status code from the server
statusMessage - Status message from the server
responseHeaders - Headers in this response

WebResponseData

protected WebResponseData(int statusCode,
                          String statusMessage,
                          List<NameValuePair> responseHeaders)
Constructs without data stream for subclasses that override getBody().

Parameters:
statusCode - Status code from the server
statusMessage - Status message from the server
responseHeaders - Headers in this response

WebResponseData

public WebResponseData(DownloadedContent responseBody,
                       int statusCode,
                       String statusMessage,
                       List<NameValuePair> responseHeaders)
Constructor.

Parameters:
responseBody - the downloaded response body
statusCode - Status code from the server
statusMessage - Status message from the server
responseHeaders - Headers in this response
Method Detail

getBody

public byte[] getBody()
Returns the response body. This may cause memory problem for very large responses.

Returns:
response body

getInputStream

public InputStream getInputStream()
                           throws IOException
Returns a new InputStream allowing to read the downloaded content.

Returns:
the associated InputStream
Throws:
IOException - in case of IO problems

getResponseHeaders

public List<NameValuePair> getResponseHeaders()
Returns:
response headers

getStatusCode

public int getStatusCode()
Returns:
response status code

getStatusMessage

public String getStatusMessage()
Returns:
response status message

cleanUp

public void cleanUp()
Clean up the downloaded content.



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