public class HTTPResponseContent
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CONTENT_READ_CHUNKED
The content was read in chunks because the HTTP response header field 'Transfer-Encoding: chunked' was set.
|
static int |
CONTENT_READ_FIXED_LENGTH
The content was read by the size set in the HTTP response header field 'Content-Length'.
|
static int |
CONTENT_READ_IGNORED
The content was not read because a HTTP 'HEAD' request was sent, or because a HTTP V1.1+ response header contains no information about how to process the received content (normal case for '204 No Content' responses).
|
static int |
CONTENT_READ_UNTIL_END_OF_STREAM
The content was read until the end of the stream because a HTTP 1.0 response has received with no hint about how to read the content.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getContent()
High-level function: Get the (decompressed) response content as a single byte array.
|
java.lang.String |
getContentAsString()
High-level function: Get the (decompressed) response content as a string.
|
int |
getContentReadMethod()
Get the way how the content was read.
|
long |
getContentReceiveTimeMillis()
Get the elapsed time duration for receiving the content data.
|
HTTPRequestHeader |
getHttpRequestHeader()
Get the corresponding HTTP request header which was sent to the server.
|
HTTPResponseHeader |
getHttpResponseHeader()
Get the corresponding HTTP response header which was received from the server.
|
byte[] |
getRawMergedContent()
High-level function: Merge the raw received content fragments to one byte array (without any control chars in case if a chunked content was received).
|
java.util.ArrayList<byte[]> |
getRawReceivedContent()
Get the raw received content (which my be truncated), without any control chars in case if a chunked content was received.
|
long |
getRawReceivedContentLength()
Get the raw received content length (the number of the received response content bytes from the Web server).
|
long |
getStartContentReceiveTimestamp()
Get the timestamp of the start of receiving the content data.
|
boolean |
hasContent()
Get if any content has received.
|
boolean |
isContentTruncated()
Get if the stored content is truncated.
|
JsonObject |
toJsonObject()
Get a JSON object of this instance (the decompressed response content in Base64 format, which can be also have a decoded size of zero bytes in case of no content).
|
void |
traceContent()
Trace the HTTP response content.
|
public static final int CONTENT_READ_IGNORED
public static final int CONTENT_READ_FIXED_LENGTH
public static final int CONTENT_READ_CHUNKED
public static final int CONTENT_READ_UNTIL_END_OF_STREAM
public HTTPRequestHeader getHttpRequestHeader()
public HTTPResponseHeader getHttpResponseHeader()
public int getContentReadMethod()
CONTENT_READ_IGNORED
,
CONTENT_READ_FIXED_LENGTH
,
CONTENT_READ_CHUNKED
,
CONTENT_READ_UNTIL_END_OF_STREAM
public boolean hasContent()
public boolean isContentTruncated()
HTTPClient.setMaxStoredHTTPResponseContentLength(long)
,
HTTPClient.getMaxStoredHTTPResponseContentLength()
public long getRawReceivedContentLength()
public java.util.ArrayList<byte[]> getRawReceivedContent()
isContentTruncated()
,
HTTPClient.setMaxStoredHTTPResponseContentLength(long)
,
HTTPClient.getMaxStoredHTTPResponseContentLength()
public byte[] getRawMergedContent() throws HTTPContentTooLargeException, HTTPContentTruncatedException
HTTPContentTooLargeException
- if the received content is larger than 2^31-1 bytesHTTPContentTruncatedException
- if the stored HTTP response content was truncated (but was still fully read)HTTPClient.setMaxStoredHTTPResponseContentLength(long)
,
HTTPClient.getMaxStoredHTTPResponseContentLength()
,
isContentTruncated()
public byte[] getContent() throws HTTPContentTooLargeException, HTTPContentTruncatedException, java.io.IOException
HTTPContentTooLargeException
- if the received content is larger than 2^31-1 bytesHTTPContentTruncatedException
- if the stored HTTP response content was truncated (but was still fully read)java.io.IOException
- if the content was compressed and the decompression failsHTTPClient.setMaxStoredHTTPResponseContentLength(long)
,
HTTPClient.getMaxStoredHTTPResponseContentLength()
,
isContentTruncated()
public java.lang.String getContentAsString() throws HTTPContentTooLargeException, HTTPContentTruncatedException, java.io.IOException
HTTPContentTooLargeException
- if the received content is larger than 2^31-1 bytesHTTPContentTruncatedException
- if the stored HTTP response content was truncated (but was still fully read)java.io.IOException
- if the content was compressed and the decompression failsHTTPClient.setMaxStoredHTTPResponseContentLength(long)
,
HTTPClient.getMaxStoredHTTPResponseContentLength()
,
isContentTruncated()
public long getStartContentReceiveTimestamp()
public long getContentReceiveTimeMillis()
public void traceContent() throws java.io.IOException
java.io.IOException
- if the content was compressed and the decompression failsHTTPClient.setTraceRequestContentTypesSet(HashSet)
public JsonObject toJsonObject() throws HTTPContentTooLargeException, HTTPContentTruncatedException, java.io.IOException
HTTPContentTooLargeException
- if the received content is larger than 2^31-1 bytesHTTPContentTruncatedException
- if the stored HTTP response content was truncated (but was still fully read)java.io.IOException
- if the content was compressed and the decompression fails