public interface RequestBody
Modifier and Type | Method and Description |
---|---|
default JsonArray |
asJsonArray() |
JsonArray |
asJsonArray(int maxAllowedLength)
Gets the current body buffer as a
JsonArray . |
default JsonObject |
asJsonObject() |
JsonObject |
asJsonObject(int maxAllowedLength)
Gets the current body buffer as a
JsonObject . |
default <R> R |
asPojo(Class<R> clazz) |
<R> R |
asPojo(Class<R> clazz,
int maxAllowedLength) |
String |
asString() |
String |
asString(String encoding)
Get the entire HTTP request body as a string, assuming the specified encoding.
|
boolean |
available()
Return
true if a BodyHandler was executed before this call in the lifetime
of the request. |
Buffer |
buffer() |
default boolean |
isEmpty()
A body can be empty if it is not available, or its length is
0 . |
int |
length()
Returns the total length of the body buffer.
|
String asString()
BodyHandler
for this to be populated.String asString(String encoding)
BodyHandler
for this to be populated.encoding
- the encoding, e.g. "UTF-16"JsonObject asJsonObject(int maxAllowedLength)
JsonObject
. If a positive limit is provided the parsing will only happen
if the buffer length is smaller or equal to the limit. Otherwise an IllegalStateException
is thrown.
When the application is only handling uploads in JSON format, it is recommended to set a limit on
BodyHandler.setBodyLimit(long)
as this will avoid the upload to be parsed and
loaded into the application memory.maxAllowedLength
- if the current buffer length is greater than the limit an IllegalStateException
is
thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take
over the CPU while attempting to parse the data.JsonObject
. The context must have first been routed to a
BodyHandler
for this to be populated.
null
or the "null"
JSON literal then null
is returned.JsonArray asJsonArray(int maxAllowedLength)
JsonArray
. If a positive limit is provided the parsing will only happen
if the buffer length is smaller or equal to the limit. Otherwise an IllegalStateException
is thrown.
When the application is only handling uploads in JSON format, it is recommended to set a limit on
BodyHandler.setBodyLimit(long)
as this will avoid the upload to be parsed and
loaded into the application memory.maxAllowedLength
- if the current buffer length is greater than the limit an IllegalStateException
is
thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take
over the CPU while attempting to parse the data.JsonArray
. The context must have first been routed to a
BodyHandler
for this to be populated.
null
or the "null"
JSON literal then null
is returned.default JsonObject asJsonObject()
JsonObject
. The context must have first been routed to a
BodyHandler
for this to be populated.
null
or the "null"
JSON literal then null
is returned.default JsonArray asJsonArray()
JsonArray
. The context must have first been routed to a
BodyHandler
for this to be populated.
null
or the "null"
JSON literal then null
is returned.Buffer buffer()
Buffer
. The context must have first been routed to a
BodyHandler
for this to be populated.<R> R asPojo(Class<R> clazz, int maxAllowedLength)
maxAllowedLength
- if the current buffer length is greater than the limit an IllegalStateException
is
thrown. This can be used to avoid DDoS attacks on very long JSON payloads that could take
over the CPU while attempting to parse the data.BodyHandler
for this to be populated.
null
or the "null"
JSON literal then null
is returned.
WARNING: This feature requires jackson-databind. Or another JSON codec that implements POJO parsingdefault <R> R asPojo(Class<R> clazz)
BodyHandler
for this to be populated.
null
or the "null"
JSON literal then null
is returned.
WARNING: This feature requires jackson-databind. Or another JSON codec that implements POJO parsingint length()
-1
.default boolean isEmpty()
0
.true
if empty.boolean available()
true
if a BodyHandler
was executed before this call in the lifetime
of the request.true
if body was parsed during the duration of the request.Copyright © 2024 Eclipse. All rights reserved.