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: 4676 $
Author:
Brad Clarke, Daniel Gredler, Ahmed Ashour
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(InputStream bodyStream, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Constructs with a data stream to minimize copying of the entire body.
protected WebResponseData(int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Constructs without data stream for subclasses that override getBody().
 
Method Summary
 byte[] getBody()
          Returns the response body.
protected  byte[] getBody(InputStream stream, List<NameValuePair> headers)
          Returns the body byte array contained by the specified input stream.
 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

public WebResponseData(InputStream bodyStream,
                       int statusCode,
                       String statusMessage,
                       List<NameValuePair> responseHeaders)
                throws IOException
Constructs 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<NameValuePair> responseHeaders)
                   throws IOException
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
Throws:
IOException - on stream errors
Method Detail

getBody

protected byte[] getBody(InputStream stream,
                         List<NameValuePair> 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()
Returns the response body.

Returns:
response body

getResponseHeaders

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

getStatusCode

public int getStatusCode()
Returns:
response status code

getStatusMessage

public String getStatusMessage()
Returns:
response status message


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