public class HttpResponseBody extends HttpBody
DEFAULT_CHARSET, LIMIT_INITIAL_CAPACITY
Constructor and Description |
---|
HttpResponseBody()
Constructs a
HttpResponseBody with no contents (that is, zero length). |
HttpResponseBody(byte[] contents)
Constructs a
HttpResponseBody with the given contents . |
HttpResponseBody(int capacity)
Constructs a
HttpResponseBody with the given initial capacity. |
HttpResponseBody(String contents)
Constructs a
HttpResponseBody with the given contents , using default charset
for String related operations. |
Modifier and Type | Method and Description |
---|---|
protected String |
createString(Charset currentCharset)
Returns the
String representation of the body. |
protected Charset |
determineCharset(String contents)
Determines the
Charset of the given contents , that are being set to the body. |
append, append, append, decode, encode, equals, getBytes, getCharset, getContent, getContentEncodings, getPos, hasContentEncodingErrors, hashCode, isDetermineCharset, length, setBody, setBody, setCharset, setContent, setContentEncodings, setDetermineCharset, setLength, toString
public HttpResponseBody()
HttpResponseBody
with no contents (that is, zero length).public HttpResponseBody(int capacity)
HttpResponseBody
with the given initial capacity.
The initial capacity is limited to prevent allocating big arrays.
capacity
- the initial capacityHttpBody.LIMIT_INITIAL_CAPACITY
public HttpResponseBody(String contents)
HttpResponseBody
with the given contents
, using default charset
for String
related operations.
If the given contents
are null
the HttpResponseBody
will have no
content.
Note: If the contents are not representable with the default charset it might lead to data loss.
contents
- the contents of the body, might be null
HttpResponseBody(byte[])
,
HttpBody.DEFAULT_CHARSET
public HttpResponseBody(byte[] contents)
HttpResponseBody
with the given contents
.
If the given contents
are null
the HttpResponseBody
will have no
content.
contents
- the contents of the body, might be null
protected Charset determineCharset(String contents)
HttpBody
Charset
of the given contents
, that are being set to the body.
An attempt to prevent data loss when new contents
are set without
a Charset
.
By default returns null
.
determineCharset
in class HttpBody
contents
- the contents being set to the bodyCharset
, or null
if not known.protected String createString(Charset currentCharset)
HttpBody
String
representation of the body.
Called when the cached string representation is no longer up-to-date.
createString
in class HttpBody
currentCharset
- the current Charset
set, null
if noneString
representation of the bodyHttpBody.getBytes()