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: 5834 $
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(DownloadedContent responseBody, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Constructor.
  WebResponseData(InputStream bodyStream, int statusCode, String statusMessage, List<NameValuePair> responseHeaders)
          Deprecated. As of HtmlUnit-2.8.
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.
 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)
                throws IOException
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
Throws:
IOException - on stream errors

WebResponseData

@Deprecated
public WebResponseData(InputStream bodyStream,
                                  int statusCode,
                                  String statusMessage,
                                  List<NameValuePair> responseHeaders)
                throws IOException
Deprecated. As of HtmlUnit-2.8.

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

WebResponseData

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

Parameters:
responseBody - the downloaded response body
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

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

Returns:
response body

getInputStream

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

Returns:
the associated InputStream

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-2010 Gargoyle Software Inc.. All Rights Reserved.