Class Http2Utils


  • public final class Http2Utils
    extends java.lang.Object
    HTTP/2 utility methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static io.netty.util.AttributeKey<java.util.concurrent.CompletableFuture<io.netty.handler.codec.http2.Http2FrameStream>> FRAME_STREAM_KEY  
      static java.lang.String MAXIMUM_ACTIVE_STREAMS_VIOLATED_MSG  
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static boolean canOpenLocalStream​(io.netty.channel.Channel parentChannel)
      Checks if the local HTTP/2 endpoint can open a new stream.
      static boolean channelAvailableForReuse​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
      Checks if a stream channel is currently available for reuse.
      static void closeStreamChannel​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)  
      static java.util.concurrent.Future<io.netty.handler.codec.http2.Http2FrameStream> frameStream​(io.netty.util.AttributeMap map)  
      static io.netty.handler.codec.http2.Http2Connection http2Connection​(io.netty.channel.Channel parentChannel)  
      static io.netty.handler.codec.http2.Http2ChannelDuplexHandler http2MultiplexHandler​(boolean channelReuse, io.netty.channel.ChannelPipeline pipeline)  
      static boolean isConfiguredHttp2Connection​(io.netty.channel.Channel parentChannel)
      Check whether the channel is a http2 connection that has been configured.
      static boolean isHttp2MultiplexPipeline​(boolean channelReuse, io.netty.channel.ChannelPipeline pipeline)  
      static boolean isHttp2ParentChannelPipeline​(io.netty.channel.ChannelPipeline pipeline)  
      static boolean isHttp2Pipeline​(io.netty.channel.ChannelPipeline pipeline)
      Deprecated.
      static boolean isReusedChannel​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
      Checks if a stream channel is a previously reused channel.
      static boolean isTooManyActiveStreamsError​(java.lang.Throwable t)
      Checks if an exception is thrown because of too many active streams.
      static boolean isUnexpectedError​(long errorCode, boolean fromRemote)  
      static boolean isUnexpectedError​(io.netty.handler.codec.http2.Http2Error errorEnum)  
      static boolean isUnexpectedError​(io.netty.handler.codec.http2.Http2Error errorEnum, boolean fromRemote)
      Returns true, if the enum is a known error or unknown error code.
      static io.netty.handler.codec.http2.Http2Connection.Endpoint<io.netty.handler.codec.http2.Http2LocalFlowController> localEndpoint​(io.netty.channel.Channel parentChannel)  
      static void markChannelAvailableForReuse​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)  
      static void markChannelForReuse​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
      Mark a stream to indicate that it will be reused.
      static void setFrameStream​(io.netty.util.AttributeMap map, io.netty.handler.codec.http2.Http2FrameStream frameStream)  
      static io.netty.handler.codec.http2.Http2Exception tooManyStreamsException​(java.lang.String msg)
      Creates an Http2Exception for having too many concurrent requests.
      static void unmarkReusedStream​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
      Unmark a stream channel to indicate that reuse is completed.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FRAME_STREAM_KEY

        public static final io.netty.util.AttributeKey<java.util.concurrent.CompletableFuture<io.netty.handler.codec.http2.Http2FrameStream>> FRAME_STREAM_KEY
      • MAXIMUM_ACTIVE_STREAMS_VIOLATED_MSG

        public static final java.lang.String MAXIMUM_ACTIVE_STREAMS_VIOLATED_MSG
        See Also:
        Constant Field Values
    • Method Detail

      • http2Connection

        public static io.netty.handler.codec.http2.Http2Connection http2Connection​(io.netty.channel.Channel parentChannel)
      • localEndpoint

        public static io.netty.handler.codec.http2.Http2Connection.Endpoint<io.netty.handler.codec.http2.Http2LocalFlowController> localEndpoint​(io.netty.channel.Channel parentChannel)
      • canOpenLocalStream

        public static boolean canOpenLocalStream​(io.netty.channel.Channel parentChannel)
        Checks if the local HTTP/2 endpoint can open a new stream.
        Parameters:
        parentChannel - Parent HTTP/2 channel
        Returns:
        true if it can open new stream
      • isTooManyActiveStreamsError

        public static boolean isTooManyActiveStreamsError​(java.lang.Throwable t)
        Checks if an exception is thrown because of too many active streams.
        Parameters:
        t - Exception
        Returns:
        true if caused by active streams limit
      • closeStreamChannel

        public static void closeStreamChannel​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
      • http2MultiplexHandler

        public static io.netty.handler.codec.http2.Http2ChannelDuplexHandler http2MultiplexHandler​(boolean channelReuse,
                                                                                                   io.netty.channel.ChannelPipeline pipeline)
      • isHttp2MultiplexPipeline

        public static boolean isHttp2MultiplexPipeline​(boolean channelReuse,
                                                       io.netty.channel.ChannelPipeline pipeline)
      • isHttp2Pipeline

        @Deprecated
        public static boolean isHttp2Pipeline​(io.netty.channel.ChannelPipeline pipeline)
        Deprecated.
      • isHttp2ParentChannelPipeline

        public static boolean isHttp2ParentChannelPipeline​(io.netty.channel.ChannelPipeline pipeline)
      • channelAvailableForReuse

        public static boolean channelAvailableForReuse​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
        Checks if a stream channel is currently available for reuse.
        Parameters:
        streamChannel - Stream channel
        Returns:
        true if available for reuse
      • isReusedChannel

        public static boolean isReusedChannel​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
        Checks if a stream channel is a previously reused channel.
        Parameters:
        streamChannel - Stream channel
        Returns:
        true if reused
      • markChannelForReuse

        public static void markChannelForReuse​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
        Mark a stream to indicate that it will be reused.
        Parameters:
        streamChannel - Stream channel
      • unmarkReusedStream

        public static void unmarkReusedStream​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
        Unmark a stream channel to indicate that reuse is completed.
        Parameters:
        streamChannel - Stream channel
      • markChannelAvailableForReuse

        public static void markChannelAvailableForReuse​(io.netty.handler.codec.http2.Http2StreamChannel streamChannel)
      • tooManyStreamsException

        public static io.netty.handler.codec.http2.Http2Exception tooManyStreamsException​(java.lang.String msg)
        Creates an Http2Exception for having too many concurrent requests.
        Parameters:
        msg - Exception message
        Returns:
        Exception
      • isUnexpectedError

        public static boolean isUnexpectedError​(long errorCode,
                                                boolean fromRemote)
      • isUnexpectedError

        public static boolean isUnexpectedError​(@Nullable
                                                io.netty.handler.codec.http2.Http2Error errorEnum)
      • isUnexpectedError

        public static boolean isUnexpectedError​(@Nullable
                                                io.netty.handler.codec.http2.Http2Error errorEnum,
                                                boolean fromRemote)
        Returns true, if the enum is a known error or unknown error code.
      • isConfiguredHttp2Connection

        public static boolean isConfiguredHttp2Connection​(@Nonnull
                                                          io.netty.channel.Channel parentChannel)
        Check whether the channel is a http2 connection that has been configured.
        Parameters:
        parentChannel - http Channel
      • frameStream

        public static java.util.concurrent.Future<io.netty.handler.codec.http2.Http2FrameStream> frameStream​(io.netty.util.AttributeMap map)
      • setFrameStream

        public static void setFrameStream​(io.netty.util.AttributeMap map,
                                          io.netty.handler.codec.http2.Http2FrameStream frameStream)