Package io.netty5.handler.codec.http
Class HttpObjectEncoder<H extends HttpMessage>
- java.lang.Object
-
- io.netty5.channel.ChannelHandlerAdapter
-
- io.netty5.handler.codec.MessageToMessageEncoder<Object>
-
- io.netty5.handler.codec.http.HttpObjectEncoder<H>
-
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
- Direct Known Subclasses:
HttpRequestEncoder,HttpResponseEncoder,RtspEncoder
public abstract class HttpObjectEncoder<H extends HttpMessage> extends io.netty5.handler.codec.MessageToMessageEncoder<Object>
Encodes anHttpMessageor anHttpContentinto aBuffer.Extensibility
Please note that this encoder is designed to be extended to implement a protocol derived from HTTP, such as RTSP and ICAP. To implement the encoder of such a derived protocol, extend this class and implement all abstract methods properly.
-
-
Constructor Summary
Constructors Constructor Description HttpObjectEncoder()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleanacceptOutboundMessage(Object msg)protected io.netty5.buffer.api.BuffercrlfBuffer(io.netty5.buffer.api.BufferAllocator allocator)protected voidencode(io.netty5.channel.ChannelHandlerContext ctx, Object msg, List<Object> out)protected voidencodeHeaders(HttpHeaders headers, io.netty5.buffer.api.Buffer buf)Encode theHttpHeadersinto aBuffer.protected abstract voidencodeInitialLine(io.netty5.buffer.api.Buffer buf, H message)protected booleanisContentAlwaysEmpty(H msg)Determine whether a message has a content or not.protected voidsanitizeHeadersBeforeEncode(H msg, boolean isAlwaysEmpty)Allows to sanitize headers of the message before encoding these.protected io.netty5.buffer.api.BufferzeroCrlfCrlfBuffer(io.netty5.buffer.api.BufferAllocator allocator)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelInactive, channelRead, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, exceptionCaught, flush, handlerAdded, handlerRemoved, read, register, userEventTriggered
-
-
-
-
Method Detail
-
encode
protected void encode(io.netty5.channel.ChannelHandlerContext ctx, Object msg, List<Object> out) throws Exception
-
encodeHeaders
protected void encodeHeaders(HttpHeaders headers, io.netty5.buffer.api.Buffer buf)
Encode theHttpHeadersinto aBuffer.
-
sanitizeHeadersBeforeEncode
protected void sanitizeHeadersBeforeEncode(H msg, boolean isAlwaysEmpty)
Allows to sanitize headers of the message before encoding these.
-
isContentAlwaysEmpty
protected boolean isContentAlwaysEmpty(H msg)
Determine whether a message has a content or not. Some message may have headers indicating a content without having an actual content, e.g the response to an HEAD or CONNECT request.- Parameters:
msg- the message to test- Returns:
trueto signal the message has no content
-
encodeInitialLine
protected abstract void encodeInitialLine(io.netty5.buffer.api.Buffer buf, H message) throws Exception- Throws:
Exception
-
crlfBuffer
protected io.netty5.buffer.api.Buffer crlfBuffer(io.netty5.buffer.api.BufferAllocator allocator)
-
zeroCrlfCrlfBuffer
protected io.netty5.buffer.api.Buffer zeroCrlfCrlfBuffer(io.netty5.buffer.api.BufferAllocator allocator)
-
-