public interface Body extends ValueNode
Modifier and Type | Method and Description |
---|---|
byte[] |
bytes()
HTTP body as byte array.
|
ReadableByteChannel |
channel()
Body as readable channel.
|
static Body |
empty(Context ctx)
Empty body.
|
long |
getSize()
Size in bytes.
|
boolean |
isInMemory()
True if body is on memory.
|
static Body |
of(Context ctx,
byte[] bytes)
Creates a HTTP body from byte array.
|
static Body |
of(Context ctx,
InputStream stream,
long size)
Creates a HTTP body from input stream.
|
static Body |
of(Context ctx,
Path file)
Creates a HTTP body from file.
|
InputStream |
stream()
Body as input stream.
|
default <T> T |
to(Class<T> type)
Convert this value to the given type.
|
<T> T |
to(Type type)
Convert this body into the given type.
|
default List<String> |
toList()
Get list of values.
|
default <T> List<T> |
toList(Class<T> type)
Get list of the given type.
|
default Set<String> |
toSet()
Get set of values.
|
default String |
value(Charset charset)
HTTP body as string.
|
get, get, iterator, resolve, resolve, resolve, resolve, size
forEach, spliterator
array, booleanValue, booleanValue, byteValue, byteValue, create, create, doubleValue, doubleValue, floatValue, floatValue, hash, headers, intValue, intValue, isArray, isMissing, isObject, isPresent, isSingle, longValue, longValue, missing, name, toEnum, toEnum, toMap, toMultimap, toOptional, toOptional, toSet, value, value, value, value, valueOrNull
@Nonnull default String value(@Nonnull Charset charset)
charset
- Charset.@Nonnull byte[] bytes()
boolean isInMemory()
ServerOptions.getMaxRequestSize()
will be dump to disk.long getSize()
Content-Length
header.Content-Length
header.@Nonnull ReadableByteChannel channel()
@Nonnull InputStream stream()
@Nonnull default <T> List<T> toList(@Nonnull Class<T> type)
Value
@Nonnull default List<String> toList()
Value
@Nonnull default Set<String> toSet()
Value
@Nonnull default <T> T to(@Nonnull Class<T> type)
Value
@Nonnull <T> T to(@Nonnull Type type)
T
- Generic type.type
- Type to use.@Nonnull static Body empty(@Nonnull Context ctx)
ctx
- Current context.@Nonnull static Body of(@Nonnull Context ctx, @Nonnull InputStream stream, long size)
ctx
- Current context.stream
- Input stream.size
- Size in bytes or -1
.@Nonnull static Body of(@Nonnull Context ctx, @Nonnull byte[] bytes)
ctx
- Current context.bytes
- byte array.Copyright © 2022. All rights reserved.