Package org.htmlunit
Class WebResponseData
java.lang.Object
org.htmlunit.WebResponseData
- All Implemented Interfaces:
Serializable
Simple data object to simplify WebResponse creation.
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionWebResponseData
(byte[] body, int statusCode, String statusMessage, List<NameValuePair> responseHeaders) Constructs with a raw byte[] (mostly for testing).protected
WebResponseData
(int statusCode, String statusMessage, List<NameValuePair> responseHeaders) Constructs without data stream for subclasses that override getBody().WebResponseData
(DownloadedContent downloadedContent, int statusCode, String statusMessage, List<NameValuePair> responseHeaders) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanUp()
Clean up the downloaded content.byte[]
getBody()
Returns the response body.long
Returns length of the content data.Returns a newInputStream
allowing to read the downloaded content.getInputStreamWithBomIfApplicable
(org.apache.commons.io.ByteOrderMark... bomHeaders) INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.int
-
Constructor Details
-
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 responsestatusCode
- Status code from the serverstatusMessage
- Status message from the serverresponseHeaders
- 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 serverstatusMessage
- Status message from the serverresponseHeaders
- Headers in this response
-
WebResponseData
public WebResponseData(DownloadedContent downloadedContent, int statusCode, String statusMessage, List<NameValuePair> responseHeaders) Constructor.- Parameters:
downloadedContent
- the downloaded contentstatusCode
- Status code from the serverstatusMessage
- Status message from the serverresponseHeaders
- Headers in this response
-
-
Method Details
-
getBody
public byte[] getBody()Returns the response body. This may cause memory problem for very large responses.- Returns:
- response body
-
getInputStream
Returns a newInputStream
allowing to read the downloaded content.- Returns:
- the associated InputStream
- Throws:
IOException
- in case of IO problems
-
getInputStreamWithBomIfApplicable
public InputStream getInputStreamWithBomIfApplicable(org.apache.commons.io.ByteOrderMark... bomHeaders) throws IOException INTERNAL 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:
IOException
- in case of IO problems
-
getResponseHeaders
- Returns:
- response headers
-
getStatusCode
public int getStatusCode()- Returns:
- response status code
-
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.
-