Package io.micronaut.http.body
Interface AvailableByteBody
- All Superinterfaces:
ByteBody
- All Known Subinterfaces:
CloseableAvailableByteBody
- All Known Implementing Classes:
AvailableByteArrayBody
,AvailableNettyByteBody
This is an extension of
ByteBody
when the entire body is immediately available
(without waiting). It has the same semantics as ByteBody
, but it adds a few other
primary operations for convenience.- Since:
- 4.5.0
- Author:
- Jonas Konrad
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.http.body.ByteBody
ByteBody.BodyDiscardedException, ByteBody.SplitBackpressureMode
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull AvailableByteBody
Deprecated.default @NonNull OptionalLong
Deprecated.This method is unnecessary forAvailableByteBody
.long
length()
The length in bytes of the body.split()
For immediate buffers, backpressure is not relevant, so the backpressure modes passed tosplit(SplitBackpressureMode)
are ignored.default @NonNull CloseableAvailableByteBody
split
(@NonNull ByteBody.SplitBackpressureMode backpressureMode) Deprecated.This method is unnecessary forAvailableByteBody
.byte @NonNull []
Get this body as a byte array.Deprecated.This method is unnecessary forAvailableByteBody
.Get this body as aByteBuffer
.default @NonNull Publisher<ByteBuffer<?>>
Deprecated.This method is unnecessary forAvailableByteBody
.Convert this body to a string with the given charset.Methods inherited from interface io.micronaut.http.body.ByteBody
buffer, toInputStream
-
Method Details
-
split
For immediate buffers, backpressure is not relevant, so the backpressure modes passed tosplit(SplitBackpressureMode)
are ignored. You can use this method always. -
split
@Deprecated @NonNull default @NonNull CloseableAvailableByteBody split(@NonNull @NonNull ByteBody.SplitBackpressureMode backpressureMode) Deprecated.This method is unnecessary forAvailableByteBody
. Usesplit()
directly.This method is equivalent tosplit()
, the backpressure parameter is ignored. -
allowDiscard
Deprecated.This method is unnecessary forAvailableByteBody
, it does nothing.Signal that the upstream may discard any remaining body data. Only if all consumers of the body allow discarding will the body be discarded, otherwise it will still be sent to all consumers. It is an optional operation.Discarding may be implemented e.g. by closing the input side of an HTTP/2 stream.
This method must be called before any primary operation.
- Specified by:
allowDiscard
in interfaceByteBody
- Returns:
- This body
-
length
long length()The length in bytes of the body.- Returns:
- The length
- See Also:
-
expectedLength
Deprecated.This method is unnecessary forAvailableByteBody
. Uselength()
directly.The length in bytes of the body. Never returnsOptionalLong.empty()
forAvailableByteBody
. Uselength()
directly instead.- Specified by:
expectedLength
in interfaceByteBody
- Returns:
- The length
-
toByteArray
byte @NonNull [] toByteArray()Get this body as a byte array.This is a primary operation. After this operation, no other primary operation or
split()
may be done.- Returns:
- The bytes
-
toByteBuffer
Get this body as aByteBuffer
. Note that the buffer may bereference counted
, and the caller must take care of releasing it.This is a primary operation. After this operation, no other primary operation or
split()
may be done.- Returns:
- The bytes
-
toString
Convert this body to a string with the given charset.This is a primary operation. After this operation, no other primary operation or
split()
may be done.- Parameters:
charset
- The charset to convert the body- Returns:
- The body as a string
-
toByteBufferPublisher
Deprecated.This method is unnecessary forAvailableByteBody
. UsetoByteBuffer()
directly.Get this body as a reactive stream ofByteBuffer
s. Note that the buffers may bereference counted
, and the caller must take care of releasing them.This is a primary operation. After this operation, no other primary operation or
ByteBody.split()
may be done.- Specified by:
toByteBufferPublisher
in interfaceByteBody
- Returns:
- The streamed bytes
-
toByteArrayPublisher
Deprecated.This method is unnecessary forAvailableByteBody
. UsetoByteArray()
directly.Get this body as a reactive stream of byte arrays.This is a primary operation. After this operation, no other primary operation or
ByteBody.split()
may be done.- Specified by:
toByteArrayPublisher
in interfaceByteBody
- Returns:
- The streamed bytes
-
AvailableByteBody
, it does nothing.