Package org.htmlunit
Class WebResponseData
- java.lang.Object
-
- org.htmlunit.WebResponseData
-
- All Implemented Interfaces:
java.io.Serializable
public class WebResponseData extends java.lang.Object implements java.io.SerializableSimple data object to simplify WebResponse creation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private DownloadedContentdownloadedContent_private static org.apache.commons.logging.LogLOGprivate java.util.List<NameValuePair>responseHeaders_private intstatusCode_private java.lang.StringstatusMessage_
-
Constructor Summary
Constructors Modifier Constructor Description WebResponseData(byte[] body, int statusCode, java.lang.String statusMessage, java.util.List<NameValuePair> responseHeaders)Constructs with a raw byte[] (mostly for testing).protectedWebResponseData(int statusCode, java.lang.String statusMessage, java.util.List<NameValuePair> responseHeaders)Constructs without data stream for subclasses that override getBody().WebResponseData(DownloadedContent downloadedContent, int statusCode, java.lang.String statusMessage, java.util.List<NameValuePair> responseHeaders)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUp()Clean up the downloaded content.byte[]getBody()Returns the response body.longgetContentLength()Returns length of the content data.private static java.lang.StringgetHeader(java.util.List<NameValuePair> headers, java.lang.String name)java.io.InputStreamgetInputStream()Returns a newInputStreamallowing to read the downloaded content.java.io.InputStreamgetInputStreamWithBomIfApplicable(org.apache.commons.io.ByteOrderMark... bomHeaders)INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.java.util.List<NameValuePair>getResponseHeaders()intgetStatusCode()java.lang.StringgetStatusMessage()private java.io.InputStreamgetStream(org.apache.commons.io.ByteOrderMark... bomHeaders)
-
-
-
Field Detail
-
LOG
private static final org.apache.commons.logging.Log LOG
-
statusCode_
private final int statusCode_
-
statusMessage_
private final java.lang.String statusMessage_
-
responseHeaders_
private final java.util.List<NameValuePair> responseHeaders_
-
downloadedContent_
private final DownloadedContent downloadedContent_
-
-
Constructor Detail
-
WebResponseData
public WebResponseData(byte[] body, int statusCode, java.lang.String statusMessage, java.util.List<NameValuePair> responseHeaders)Constructs with a raw byte[] (mostly for testing).- Parameters:
body- Body of this responsestatusCode- Status code from the serverstatusMessage- Status message from the serverresponseHeaders- Headers in this response
-
WebResponseData
protected WebResponseData(int statusCode, java.lang.String statusMessage, java.util.List<NameValuePair> responseHeaders)Constructs without data stream for subclasses that override getBody().- Parameters:
statusCode- Status code from the serverstatusMessage- Status message from the serverresponseHeaders- Headers in this response
-
WebResponseData
public WebResponseData(DownloadedContent downloadedContent, int statusCode, java.lang.String statusMessage, java.util.List<NameValuePair> responseHeaders)
Constructor.- Parameters:
downloadedContent- the downloaded contentstatusCode- Status code from the serverstatusMessage- Status message from the serverresponseHeaders- Headers in this response
-
-
Method Detail
-
getStream
private java.io.InputStream getStream(org.apache.commons.io.ByteOrderMark... bomHeaders) throws java.io.IOException- Throws:
java.io.IOException
-
getHeader
private static java.lang.String getHeader(java.util.List<NameValuePair> headers, java.lang.String name)
-
getBody
public byte[] getBody()
Returns the response body. This may cause memory problem for very large responses.- Returns:
- response body
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOExceptionReturns a newInputStreamallowing to read the downloaded content.- Returns:
- the associated InputStream
- Throws:
java.io.IOException- in case of IO problems
-
getInputStreamWithBomIfApplicable
public java.io.InputStream getInputStreamWithBomIfApplicable(org.apache.commons.io.ByteOrderMark... bomHeaders) throws java.io.IOExceptionINTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.- Parameters:
bomHeaders- the supported bomHeaders- Returns:
- the associated InputStream wrapped with a bom input stream if applicable
- Throws:
java.io.IOException- in case of IO problems
-
getResponseHeaders
public java.util.List<NameValuePair> getResponseHeaders()
- Returns:
- response headers
-
getStatusCode
public int getStatusCode()
- Returns:
- response status code
-
getStatusMessage
public java.lang.String getStatusMessage()
- Returns:
- response status message
-
getContentLength
public long getContentLength()
Returns length of the content data.- Returns:
- the length
-
cleanUp
public void cleanUp()
Clean up the downloaded content.
-
-