Class AvailableNettyByteBody
- All Implemented Interfaces:
- AvailableByteBody,- ByteBody,- CloseableAvailableByteBody,- CloseableByteBody,- InternalByteBody,- Closeable,- AutoCloseable
- Since:
- 4.5.0
- Author:
- Jonas Konrad
- 
Nested Class SummaryNested classes/interfaces inherited from interface io.micronaut.http.body.ByteBodyByteBody.BodyDiscardedException, ByteBody.SplitBackpressureMode
- 
Field SummaryFields inherited from class io.micronaut.http.netty.body.NettyByteBodyLOG
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescription@NonNull ExecutionFlow<? extends CloseableAvailableByteBody>Variant ofInternalByteBody.buffer()that uses theExecutionFlowAPI for extra efficiency.voidclose()Clean up any resources held by this instance.static @NonNull CloseableByteBodycreateChecked(@NonNull io.netty.channel.EventLoop loop, @NonNull BodySizeLimits bodySizeLimits, @NonNull io.netty.buffer.ByteBuf buf) This is a wrapper aroundAvailableNettyByteBody(ByteBuf)with an extra body length check.static CloseableAvailableByteBodyempty()longlength()The length in bytes of the body.move()Create a newCloseableByteBodywith the same content but an independent lifecycle, claiming this body in the process.io.netty.buffer.ByteBufpeek()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 @NonNull io.netty.buffer.ByteBufGet 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.netty.body.NettyByteBodytoByteArrayPublisher, toByteBufferPublisher, toByteBufsMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.http.body.AvailableByteBodyexpectedLength, split, toByteArrayPublisher, toByteBufferPublisherMethods inherited from interface io.micronaut.http.body.CloseableAvailableByteBodyallowDiscardMethods inherited from interface io.micronaut.http.body.InternalByteBodybuffer
- 
Constructor Details- 
AvailableNettyByteBody
 
- 
- 
Method Details- 
empty
- 
toByteBuf@NonNull public static @NonNull io.netty.buffer.ByteBuf toByteBuf(@NonNull @NonNull AvailableByteBody body) 
- 
createChecked@NonNull public static @NonNull CloseableByteBody createChecked(@NonNull @NonNull io.netty.channel.EventLoop loop, @NonNull @NonNull BodySizeLimits bodySizeLimits, @NonNull @NonNull io.netty.buffer.ByteBuf buf) This is a wrapper aroundAvailableNettyByteBody(ByteBuf)with an extra body length check.- Parameters:
- loop- The event loop for constructing- StreamingNettyByteBody
- bodySizeLimits- The body size limits to check
- buf- The input buffer
- Returns:
- The body with the given input buffer, or a StreamingNettyByteBodywith the appropriate content length error
 
- 
peekpublic io.netty.buffer.ByteBuf peek()
- 
toInputStreamDescription copied from interface:ByteBodyGet this body as anInputStream.This is a primary operation. After this operation, no other primary operation or ByteBody.split()may be done.- Specified by:
- toInputStreamin interface- ByteBody
- Returns:
- The streamed bytes
 
- 
lengthpublic long length()Description copied from interface:AvailableByteBodyThe length in bytes of the body.- Specified by:
- lengthin interface- AvailableByteBody
- Returns:
- The length
- See Also:
 
- 
bufferFlowDescription copied from interface:InternalByteBodyVariant ofInternalByteBody.buffer()that uses theExecutionFlowAPI for extra efficiency.- Specified by:
- bufferFlowin interface- InternalByteBody
- Specified by:
- bufferFlowin class- NettyByteBody
- Returns:
- A flow that completes when all bytes are available
 
- 
closepublic void close()Description copied from interface:CloseableByteBodyClean up any resources held by this instance. See class documentation.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Specified by:
- closein interface- CloseableByteBody
 
- 
toByteBufPublisherprotected reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> toByteBufPublisher()
- 
toByteArrayDescription copied from interface:AvailableByteBodyGet 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:
- toByteArrayin interface- AvailableByteBody
- Returns:
- The bytes
 
- 
toByteBufferDescription copied from interface:AvailableByteBodyGet 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:
- toByteBufferin interface- AvailableByteBody
- Returns:
- The bytes
 
- 
moveDescription copied from interface:ByteBodyCreate a newCloseableByteBodywith the same content but an independent lifecycle, claiming this body in the process.This is a primary operation. After this operation, no other primary operation or ByteBody.split()may be done.The purpose of this method is to move the data to a different component in an application, making clear that the receiving component claims ownership of the body. If the sending component then closes the original ByteBodyfor example, it will have no impact on the newCloseableByteBodythat the receiver is working with.- Specified by:
- movein interface- ByteBody
- Returns:
- A new CloseableByteBodywith the same content.
 
- 
toStringDescription copied from interface:AvailableByteBodyConvert 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:
- toStringin interface- AvailableByteBody
- Parameters:
- charset- The charset to convert the body
- Returns:
- The body as a string
 
- 
splitDescription copied from interface:AvailableByteBodyFor immediate buffers, backpressure is not relevant, so the backpressure modes passed toAvailableByteBody.split(SplitBackpressureMode)are ignored. You can use this method always.- Specified by:
- splitin interface- AvailableByteBody
- Specified by:
- splitin interface- ByteBody
- Returns:
- A body with the same content as this one
- See Also:
 
 
-