Class StreamingNettyByteBody
java.lang.Object
io.micronaut.http.server.netty.body.NettyByteBody
io.micronaut.http.server.netty.body.StreamingNettyByteBody
- All Implemented Interfaces:
ByteBody
,CloseableByteBody
,InternalByteBody
,Closeable
,AutoCloseable
@Internal
public final class StreamingNettyByteBody
extends NettyByteBody
implements CloseableByteBody
Netty implementation for streaming ByteBody.
- Since:
- 4.5.0
- Author:
- Jonas Konrad
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
This class buffers input data and distributes it to multipleStreamingNettyByteBody
instances.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 TypeMethodDescriptionSignal that the upstream may discard any remaining body data.@NonNull ExecutionFlow<? extends CloseableAvailableByteBody>
Variant ofInternalByteBody.buffer()
that uses theExecutionFlow
API for extra efficiency.void
close()
Clean up any resources held by this instance.Get the expected length of this body, if known (either fromContent-Length
or from previous buffering).primary
(BufferConsumer primary) split
(@NonNull ByteBody.SplitBackpressureMode backpressureMode) Create a new, independentByteBody
that contains the same data as this one.protected reactor.core.publisher.Flux<io.netty.buffer.ByteBuf>
Get this body as anInputStream
.Methods inherited from class io.micronaut.http.server.netty.body.NettyByteBody
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.ByteBody
split, toByteArrayPublisher, toByteBufferPublisher
Methods inherited from interface io.micronaut.http.body.InternalByteBody
buffer
-
Constructor Details
-
Method Details
-
-
split
@NonNull public @NonNull CloseableByteBody split(@NonNull @NonNull ByteBody.SplitBackpressureMode backpressureMode) Description copied from interface:ByteBody
Create a new, independentByteBody
that contains the same data as this one.- Specified by:
split
in interfaceByteBody
- Parameters:
backpressureMode
- How to handle backpressure between the old and new body. SeeByteBody.SplitBackpressureMode
documentation- Returns:
- The newly split body. Must be closed by the caller, unless a terminal operation is performed on it
-
allowDiscard
Description copied from interface:ByteBody
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
- Specified by:
allowDiscard
in interfaceCloseableByteBody
- Returns:
- This body
-
toByteBufPublisher
protected reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> toByteBufPublisher() -
expectedLength
Description copied from interface:ByteBody
Get the expected length of this body, if known (either fromContent-Length
or from previous buffering). The actual length will never exceed this value, though it may sometimes be lower if there is a connection error.This value may go from
OptionalLong.empty()
to a known value over the lifetime of this body.This is not a primary operation and does not modify this
ByteBody
.- Specified by:
expectedLength
in interfaceByteBody
- Returns:
- The expected length of this body
-
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
-
bufferFlow
Description copied from interface:InternalByteBody
Variant ofInternalByteBody.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
-