Class Http2StreamFrameToHttpObjectCodec

  • All Implemented Interfaces:
    io.netty5.channel.ChannelHandler

    @UnstableApi
    public class Http2StreamFrameToHttpObjectCodec
    extends io.netty5.handler.codec.MessageToMessageCodec<Http2StreamFrame,​io.netty5.handler.codec.http.HttpObject>
    This handler converts from Http2StreamFrame to HttpObject, and back. It can be used as an adapter in conjunction with Http2MultiplexHandler to make http/2 connections backward-compatible with ChannelHandlers expecting HttpObject For simplicity, it converts to chunked encoding unless the entire stream is a single header.
    • Constructor Detail

      • Http2StreamFrameToHttpObjectCodec

        public Http2StreamFrameToHttpObjectCodec​(boolean isServer,
                                                 boolean validateHeaders)
      • Http2StreamFrameToHttpObjectCodec

        public Http2StreamFrameToHttpObjectCodec​(boolean isServer)
    • Method Detail

      • isSharable

        public boolean isSharable()
      • acceptInboundMessage

        public boolean acceptInboundMessage​(Object msg)
                                     throws Exception
        Overrides:
        acceptInboundMessage in class io.netty5.handler.codec.MessageToMessageCodec<Http2StreamFrame,​io.netty5.handler.codec.http.HttpObject>
        Throws:
        Exception
      • decodeAndClose

        protected void decodeAndClose​(io.netty5.channel.ChannelHandlerContext ctx,
                                      Http2StreamFrame frame)
                               throws Exception
        Overrides:
        decodeAndClose in class io.netty5.handler.codec.MessageToMessageCodec<Http2StreamFrame,​io.netty5.handler.codec.http.HttpObject>
        Throws:
        Exception
      • encodeAndClose

        protected void encodeAndClose​(io.netty5.channel.ChannelHandlerContext ctx,
                                      io.netty5.handler.codec.http.HttpObject obj,
                                      List<Object> out)
                               throws Exception
        Encode from an HttpObject to an Http2StreamFrame. This method will be called for each written message that can be handled by this encoder. NOTE: 100-Continue responses that are NOT FullHttpResponse will be rejected.
        Overrides:
        encodeAndClose in class io.netty5.handler.codec.MessageToMessageCodec<Http2StreamFrame,​io.netty5.handler.codec.http.HttpObject>
        Parameters:
        ctx - the ChannelHandlerContext which this handler belongs to
        obj - the HttpObject message to encode
        out - the List into which the encoded msg should be added needs to do some kind of aggregation
        Throws:
        Exception - is thrown if an error occurs
      • handlerAdded

        public void handlerAdded​(io.netty5.channel.ChannelHandlerContext ctx)
                          throws Exception
        Throws:
        Exception
      • isSsl

        protected boolean isSsl​(io.netty5.channel.ChannelHandlerContext ctx)