Class EspressoHttpObjectEncoder<H extends io.netty.handler.codec.http.HttpMessage>

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelOutboundHandler

    public abstract class EspressoHttpObjectEncoder<H extends io.netty.handler.codec.http.HttpMessage>
    extends EspressoMessageToMessageEncoder<java.lang.Object>
    Forked from Netty 4.1.42.Final. Main change is to extend EspressoMessageToMessageEncoder to avoid creating TypeParameterMatcher. 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 io.netty.channel.ChannelHandler

        io.netty.channel.ChannelHandler.Sharable
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean acceptOutboundMessage​(java.lang.Object msg)  
      protected void encode​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object msg, java.util.List<java.lang.Object> out)
      Encode from one message to an other.
      protected static void encodeAscii​(java.lang.String s, io.netty.buffer.ByteBuf buf)
      Deprecated.
      protected void encodeHeaders​(io.netty.handler.codec.http.HttpHeaders headers, io.netty.buffer.ByteBuf buf)
      Encode the HttpHeaders into a ByteBuf.
      protected abstract void encodeInitialLine​(io.netty.buffer.ByteBuf buf, H message)  
      protected boolean isContentAlwaysEmpty​(H msg)
      Determine whether a message has a content or not.
      protected void sanitizeHeadersBeforeEncode​(H msg, boolean isAlwaysEmpty)
      Allows to sanitize headers of the message before encoding these.
      • Methods inherited from class io.netty.channel.ChannelOutboundHandlerAdapter

        bind, close, connect, deregister, disconnect, flush, read
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface io.netty.channel.ChannelHandler

        exceptionCaught, handlerAdded, handlerRemoved
    • Constructor Detail

      • EspressoHttpObjectEncoder

        public EspressoHttpObjectEncoder()
    • Method Detail

      • encode

        protected void encode​(io.netty.channel.ChannelHandlerContext ctx,
                              java.lang.Object msg,
                              java.util.List<java.lang.Object> out)
                       throws java.lang.Exception
        Description copied from class: EspressoMessageToMessageEncoder
        Encode from one message to an other. This method will be called for each written message that can be handled by this encoder.
        Specified by:
        encode in class EspressoMessageToMessageEncoder<java.lang.Object>
        Parameters:
        ctx - the ChannelHandlerContext which this MessageToMessageEncoder belongs to
        msg - the message to encode to an other one
        out - the List into which the encoded msg should be added needs to do some kind of aggregation
        Throws:
        java.lang.Exception - is thrown if an error occurs
      • encodeHeaders

        protected void encodeHeaders​(io.netty.handler.codec.http.HttpHeaders headers,
                                     io.netty.buffer.ByteBuf buf)
        Encode the HttpHeaders into a ByteBuf.
      • 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:
        true to signal the message has no content
      • encodeAscii

        @Deprecated
        protected static void encodeAscii​(java.lang.String s,
                                          io.netty.buffer.ByteBuf buf)
        Deprecated.
      • encodeInitialLine

        protected abstract void encodeInitialLine​(io.netty.buffer.ByteBuf buf,
                                                  H message)
                                           throws java.lang.Exception
        Throws:
        java.lang.Exception