Class HttpObjectEncoder<H extends HttpMessage>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelOutboundHandlerAdapter
io.netty.handler.codec.MessageToMessageEncoder<Object>
io.netty.handler.codec.http.HttpObjectEncoder<H>
- All Implemented Interfaces:
ChannelHandler, ChannelOutboundHandler
- Direct Known Subclasses:
HttpRequestEncoder, HttpResponseEncoder, RtspEncoder, RtspObjectEncoder
public abstract class HttpObjectEncoder<H extends HttpMessage>
extends MessageToMessageEncoder<Object>
Encodes an
HttpMessage or an HttpContent into
a ByteBuf.
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the given message should be handled.protected voidencode(ChannelHandlerContext ctx, Object msg, List<Object> out) Encode from one message to an other.protected static voidencodeAscii(String s, ByteBuf buf) Deprecated.protected voidencodeHeaders(HttpHeaders headers, ByteBuf buf) Encode theHttpHeadersinto aByteBuf.protected abstract voidencodeInitialLine(ByteBuf 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.voidwrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) CallsChannelOutboundInvoker.write(Object, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline.Methods inherited from class ChannelOutboundHandlerAdapter
bind, close, connect, deregister, disconnect, flush, readMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
exceptionCaught, handlerAdded, handlerRemoved
-
Constructor Details
-
HttpObjectEncoder
public HttpObjectEncoder()
-
-
Method Details
-
write
Description copied from class:ChannelOutboundHandlerAdapterCallsChannelOutboundInvoker.write(Object, ChannelPromise)to forward to the nextChannelOutboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
writein interfaceChannelOutboundHandler- Overrides:
writein classMessageToMessageEncoder<Object>- Parameters:
ctx- theChannelHandlerContextfor which the write operation is mademsg- the message to writepromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
encode
Description copied from class:MessageToMessageEncoderEncode from one message to an other. This method will be called for each written message that can be handled by this encoder.- Specified by:
encodein classMessageToMessageEncoder<Object>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToMessageEncoderbelongs tomsg- the message to encode to an other oneout- theListinto which the encoded msg should be added needs to do some kind of aggregation- Throws:
Exception- is thrown if an error occurs
-
encodeHeaders
Encode theHttpHeadersinto aByteBuf. -
sanitizeHeadersBeforeEncode
Allows to sanitize headers of the message before encoding these. -
isContentAlwaysEmpty
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
-
acceptOutboundMessage
Description copied from class:MessageToMessageEncoderReturnstrueif the given message should be handled. Iffalseit will be passed to the nextChannelOutboundHandlerin theChannelPipeline.- Overrides:
acceptOutboundMessagein classMessageToMessageEncoder<Object>- Throws:
Exception
-
encodeAscii
Deprecated. -
encodeInitialLine
-