Package io.micronaut.http.netty.body
Class ByteBufRawMessageBodyHandler
java.lang.Object
io.micronaut.http.netty.body.ByteBufRawMessageBodyHandler
- All Implemented Interfaces:
ChunkedMessageBodyReader<io.netty.buffer.ByteBuf>
,MessageBodyHandler<io.netty.buffer.ByteBuf>
,MessageBodyReader<io.netty.buffer.ByteBuf>
,MessageBodyWriter<io.netty.buffer.ByteBuf>
,RawMessageBodyHandler<io.netty.buffer.ByteBuf>
@Internal
@Singleton
@Bean(typed=RawMessageBodyHandler.class)
public final class ByteBufRawMessageBodyHandler
extends Object
implements RawMessageBodyHandler<io.netty.buffer.ByteBuf>
Handler for netty
ByteBuf
.- Since:
- 4.0.0
- Author:
- Jonas Konrad
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionCollection<Class<io.netty.buffer.ByteBuf>>
getTypes()
Supported types of this raw body handler.io.netty.buffer.ByteBuf
read
(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, ByteBuffer<?> byteBuffer) Reads an object from the given byte buffer.io.netty.buffer.ByteBuf
read
(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, InputStream inputStream) Reads an object from the given byte buffer.Publisher<io.netty.buffer.ByteBuf>
readChunked
(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input) ByteBuffer<?>
writeTo
(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, io.netty.buffer.ByteBuf object, MutableHeaders outgoingHeaders, ByteBufferFactory<?, ?> bufferFactory) Writes an object to the given stream.void
writeTo
(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, io.netty.buffer.ByteBuf object, MutableHeaders outgoingHeaders, OutputStream outputStream) Writes an object to the given output stream.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.MessageBodyReader
isReadable
Methods inherited from interface io.micronaut.http.body.MessageBodyWriter
createSpecific, isBlocking, isWriteable
-
Constructor Details
-
ByteBufRawMessageBodyHandler
public ByteBufRawMessageBodyHandler()
-
-
Method Details
-
readChunked
public Publisher<io.netty.buffer.ByteBuf> readChunked(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, Publisher<ByteBuffer<?>> input) - Specified by:
readChunked
in interfaceChunkedMessageBodyReader<io.netty.buffer.ByteBuf>
-
read
public io.netty.buffer.ByteBuf read(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, ByteBuffer<?> byteBuffer) throws CodecException Description copied from interface:MessageBodyReader
Reads an object from the given byte buffer.- Specified by:
read
in interfaceMessageBodyReader<io.netty.buffer.ByteBuf>
- Parameters:
type
- The type being decoded.mediaType
- The media type, can benull
httpHeaders
- The HTTP headersbyteBuffer
- The byte buffer- Returns:
- The read object or
null
- Throws:
CodecException
- If an error occurs decoding
-
read
public io.netty.buffer.ByteBuf read(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, Headers httpHeaders, InputStream inputStream) throws CodecException Description copied from interface:MessageBodyReader
Reads an object from the given byte buffer.- Specified by:
read
in interfaceMessageBodyReader<io.netty.buffer.ByteBuf>
- Parameters:
type
- The type being decoded.mediaType
- The media type, can benull
httpHeaders
- The HTTP headersinputStream
- The input stream- Returns:
- The read object or
null
- Throws:
CodecException
- If an error occurs decoding
-
writeTo
public void writeTo(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, io.netty.buffer.ByteBuf object, MutableHeaders outgoingHeaders, OutputStream outputStream) throws CodecException Description copied from interface:MessageBodyWriter
Writes an object to the given output stream.- Specified by:
writeTo
in interfaceMessageBodyWriter<io.netty.buffer.ByteBuf>
- Parameters:
type
- The typemediaType
- The media typeobject
- The object to writeoutgoingHeaders
- The HTTP headersoutputStream
- The output stream- Throws:
CodecException
- If an error occurs decoding
-
writeTo
public ByteBuffer<?> writeTo(Argument<io.netty.buffer.ByteBuf> type, MediaType mediaType, io.netty.buffer.ByteBuf object, MutableHeaders outgoingHeaders, ByteBufferFactory<?, ?> bufferFactory) throws CodecExceptionDescription copied from interface:MessageBodyWriter
Writes an object to the given stream.- Specified by:
writeTo
in interfaceMessageBodyWriter<io.netty.buffer.ByteBuf>
- Parameters:
type
- The typemediaType
- The media typeobject
- The object to writeoutgoingHeaders
- The HTTP headersbufferFactory
- A byte buffer factory- Returns:
- The encoded byte buffer
- Throws:
CodecException
- If an error occurs decoding
-
getTypes
Description copied from interface:RawMessageBodyHandler
Supported types of this raw body handler. Exact match is used for reading. For writing, the match is covariant. For example, if this returns[String, CharSequence]
, then this raw handler will be used for reading types declared as exactlyString
orCharSequence
, and will additionally be used for writing (but not reading) subtypes (e.g.StringBuilder
).- Specified by:
getTypes
in interfaceRawMessageBodyHandler<io.netty.buffer.ByteBuf>
- Returns:
- The supported types
-