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: 2132 $
Author:
Brad Clarke, Daniel Gredler, Ahmed Ashour
See Also:
Serialized Form

Constructor Summary
  WebResponseData(byte[] body, int statusCode, String statusMessage, List responseHeaders)
          Construct with a raw byte[] (mostly for testing)
  WebResponseData(InputStream bodyStream, int statusCode, String statusMessage, List responseHeaders)
          Construct with a data stream to minimize copying of the entire body.
protected WebResponseData(int statusCode, String statusMessage, List responseHeaders)
          Construct without data stream for subclasses that override getBody()
 
Method Summary
 byte[] getBody()
          Return the response body.
protected  byte[] getBody(InputStream stream, List headers)
          Returns the body byte array contained by the specified input stream.
 List 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 responseHeaders)
Construct 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

public WebResponseData(InputStream bodyStream,
                       int statusCode,
                       String statusMessage,
                       List responseHeaders)
                throws IOException
Construct with a data stream to minimize copying of the entire body.

Parameters:
bodyStream - Stream of this response's body
statusCode - Status code from the server
statusMessage - Status message from the server
responseHeaders - Headers in this response
Throws:
IOException - on stream errors

WebResponseData

protected WebResponseData(int statusCode,
                          String statusMessage,
                          List responseHeaders)
                   throws IOException
Construct 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
Throws:
IOException - on stream errors
Method Detail

getBody

protected byte[] getBody(InputStream stream,
                         List headers)
                  throws IOException
Returns the body byte array contained by the specified input stream. If the response headers indicate that the data has been compressed, the data stream is handled appropriately. If the specified stream is null, this method returns null.

Parameters:
stream - The input stream which contains the body.
headers - The response headers.
Returns:
The specified body stream, as a byte array.
Throws:
IOException - If a stream error occurs.

getBody

public byte[] getBody()
Return the response body.

Returns:
response body.

getResponseHeaders

public List getResponseHeaders()
Returns:
response headers

getStatusCode

public int getStatusCode()
Returns:
response status code

getStatusMessage

public String getStatusMessage()
Returns:
response status message


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