Package org.zaproxy.zap.network
Class HttpResponseBody
- java.lang.Object
-
- org.parosproxy.paros.network.HttpBody
-
- org.zaproxy.zap.network.HttpResponseBody
-
public class HttpResponseBody extends HttpBody
-
-
Field Summary
-
Fields inherited from class org.parosproxy.paros.network.HttpBody
DEFAULT_CHARSET, LIMIT_INITIAL_CAPACITY
-
-
Constructor Summary
Constructors Constructor Description HttpResponseBody()
Constructs aHttpResponseBody
with no contents (that is, zero length).HttpResponseBody(byte[] contents)
Constructs aHttpResponseBody
with the givencontents
.HttpResponseBody(int capacity)
Constructs aHttpResponseBody
with the given initial capacity.HttpResponseBody(java.lang.String contents)
Constructs aHttpResponseBody
with the givencontents
, using default charset forString
related operations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.String
createString(java.nio.charset.Charset currentCharset)
Returns theString
representation of the body.protected java.nio.charset.Charset
determineCharset(java.lang.String contents)
Determines theCharset
of the givencontents
, that are being set to the body.-
Methods inherited from class org.parosproxy.paros.network.HttpBody
append, append, append, decode, encode, equals, getBytes, getCharset, getContent, getContentEncodings, getPos, hasContentEncodingErrors, hashCode, isDetermineCharset, length, setBody, setBody, setCharset, setContent, setContentEncodings, setDetermineCharset, setLength, toString
-
-
-
-
Constructor Detail
-
HttpResponseBody
public HttpResponseBody()
Constructs aHttpResponseBody
with no contents (that is, zero length).
-
HttpResponseBody
public HttpResponseBody(int capacity)
Constructs aHttpResponseBody
with the given initial capacity.The initial capacity is limited to prevent allocating big arrays.
- Parameters:
capacity
- the initial capacity- See Also:
HttpBody.LIMIT_INITIAL_CAPACITY
-
HttpResponseBody
public HttpResponseBody(java.lang.String contents)
Constructs aHttpResponseBody
with the givencontents
, using default charset forString
related operations.If the given
contents
arenull
theHttpResponseBody
will have no content.Note: If the contents are not representable with the default charset it might lead to data loss.
- Parameters:
contents
- the contents of the body, might benull
- See Also:
HttpResponseBody(byte[])
,HttpBody.DEFAULT_CHARSET
-
HttpResponseBody
public HttpResponseBody(byte[] contents)
Constructs aHttpResponseBody
with the givencontents
.If the given
contents
arenull
theHttpResponseBody
will have no content.- Parameters:
contents
- the contents of the body, might benull
- Since:
- 2.5.0
-
-
Method Detail
-
determineCharset
protected java.nio.charset.Charset determineCharset(java.lang.String contents)
Description copied from class:HttpBody
Determines theCharset
of the givencontents
, that are being set to the body.An attempt to prevent data loss when
new contents
are set without aCharset
.By default returns
null
.- Overrides:
determineCharset
in classHttpBody
- Parameters:
contents
- the contents being set to the body- Returns:
- the
Charset
, ornull
if not known.
-
createString
protected java.lang.String createString(java.nio.charset.Charset currentCharset)
Description copied from class:HttpBody
Returns theString
representation of the body.Called when the cached string representation is no longer up-to-date.
- Overrides:
createString
in classHttpBody
- Parameters:
currentCharset
- the currentCharset
set,null
if none- Returns:
- the
String
representation of the body - See Also:
HttpBody.getBytes()
-
-