Class AvailableNettyByteBody
java.lang.Object
io.micronaut.http.server.netty.body.NettyByteBody
io.micronaut.http.server.netty.body.AvailableNettyByteBody
- All Implemented Interfaces:
AvailableByteBody
,ByteBody
,CloseableAvailableByteBody
,CloseableByteBody
,InternalByteBody
,Closeable
,AutoCloseable
@Internal
public final class AvailableNettyByteBody
extends NettyByteBody
implements CloseableAvailableByteBody
Netty ByteBuf implementation of ImmediateByteBody.
- 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
-
Field Summary
Fields inherited from class io.micronaut.http.server.netty.body.NettyByteBody
LOG
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@NonNull ExecutionFlow<? extends CloseableAvailableByteBody>
Variant ofByteBody.buffer()
that uses theExecutionFlow
API for extra efficiency.void
close()
Clean up any resources held by this instance.static CloseableAvailableByteBody
empty()
long
length()
The length in bytes of the body.io.netty.buffer.ByteBuf
peek()
split()
For immediate buffers, backpressure is not relevant, so the backpressure modes passed toAvailableByteBody.split(SplitBackpressureMode)
are ignored.byte @NonNull []
Get this body as a byte array.static io.netty.buffer.ByteBuf
toByteBuf
(AvailableByteBody body) Get this body as aByteBuffer
.protected reactor.core.publisher.Flux<io.netty.buffer.ByteBuf>
Get this body as anInputStream
.Convert this body to a string with the given charset.Methods inherited from class io.micronaut.http.server.netty.body.NettyByteBody
buffer, toByteArrayPublisher, toByteBufferPublisher, toByteBufs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.http.body.AvailableByteBody
expectedLength, split, toByteArrayPublisher, toByteBufferPublisher
Methods inherited from interface io.micronaut.http.body.CloseableAvailableByteBody
allowDiscard
-
Constructor Details
-
AvailableNettyByteBody
-
-
Method Details
-
empty
-
toByteBuf
-
peek
public io.netty.buffer.ByteBuf peek() -
toInputStream
Description copied from interface:ByteBody
Get this body as anInputStream
.This is a primary operation. After this operation, no other primary operation or
ByteBody.split()
may be done.- Specified by:
toInputStream
in interfaceByteBody
- Returns:
- The streamed bytes
-
length
public long length()Description copied from interface:AvailableByteBody
The length in bytes of the body.- Specified by:
length
in interfaceAvailableByteBody
- Returns:
- The length
- See Also:
-
bufferFlow
Description copied from interface:InternalByteBody
Variant ofByteBody.buffer()
that uses theExecutionFlow
API for extra efficiency.- Specified by:
bufferFlow
in interfaceInternalByteBody
- Specified by:
bufferFlow
in classNettyByteBody
- Returns:
- A flow that completes when all bytes are available
-
close
public void close()Description copied from interface:CloseableByteBody
Clean up any resources held by this instance. See class documentation.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceCloseableByteBody
-
toByteBufPublisher
protected reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> toByteBufPublisher() -
toByteArray
Description copied from interface:AvailableByteBody
Get this body as a byte array.This is a primary operation. After this operation, no other primary operation or
AvailableByteBody.split()
may be done.- Specified by:
toByteArray
in interfaceAvailableByteBody
- Returns:
- The bytes
-
toByteBuffer
Description copied from interface:AvailableByteBody
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
AvailableByteBody.split()
may be done.- Specified by:
toByteBuffer
in interfaceAvailableByteBody
- Returns:
- The bytes
-
toString
Description copied from interface:AvailableByteBody
Convert this body to a string with the given charset.This is a primary operation. After this operation, no other primary operation or
AvailableByteBody.split()
may be done.- Specified by:
toString
in interfaceAvailableByteBody
- Parameters:
charset
- The charset to convert the body- Returns:
- The body as a string
-
split
Description copied from interface:AvailableByteBody
For immediate buffers, backpressure is not relevant, so the backpressure modes passed toAvailableByteBody.split(SplitBackpressureMode)
are ignored. You can use this method always.- Specified by:
split
in interfaceAvailableByteBody
- Specified by:
split
in interfaceByteBody
- Returns:
- A body with the same content as this one
- See Also:
-