Class BasicHttpObjectDecoder

  • All Implemented Interfaces:
    io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
    Direct Known Subclasses:
    HttpContentMultiPartDecode

    public abstract class BasicHttpObjectDecoder
    extends io.netty.handler.codec.http.HttpObjectDecoder
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  BasicHttpObjectDecoder.State
      The internal state of BasicHttpObjectDecoder.
      • Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder

        io.netty.handler.codec.ByteToMessageDecoder.Cumulator
      • Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

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

      Fields 
      Modifier and Type Field Description
      protected boolean validateHeaders  
      • Fields inherited from class io.netty.handler.codec.http.HttpObjectDecoder

        DEFAULT_ALLOW_DUPLICATE_CONTENT_LENGTHS, DEFAULT_CHUNKED_SUPPORTED, DEFAULT_INITIAL_BUFFER_SIZE, DEFAULT_MAX_CHUNK_SIZE, DEFAULT_MAX_HEADER_SIZE, DEFAULT_MAX_INITIAL_LINE_LENGTH, DEFAULT_VALIDATE_HEADERS
      • Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder

        COMPOSITE_CUMULATOR, MERGE_CUMULATOR
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BasicHttpObjectDecoder()
      Creates a new instance with the default maxInitialLineLength (4096}, maxHeaderSize (8192), and maxChunkSize (8192).
      protected BasicHttpObjectDecoder​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported)
      Creates a new instance with the specified parameters.
      protected BasicHttpObjectDecoder​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported, boolean validateHeaders)
      Creates a new instance with the specified parameters.
      protected BasicHttpObjectDecoder​(int maxInitialLineLength, int maxHeaderSize, int maxChunkSize, boolean chunkedSupported, boolean validateHeaders, int initialBufferSize)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract io.netty.handler.codec.http.HttpMessage createInvalidMessage()  
      protected io.netty.handler.codec.http.HttpMessage createMessage​(ByteBufAsciiString[] initialLine)  
      protected abstract io.netty.handler.codec.http.HttpMessage createMessage​(java.lang.String[] initialLine)  
      protected void decode​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, java.util.List<java.lang.Object> out)  
      protected void decodeLast​(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, java.util.List<java.lang.Object> out)  
      BasicHttpObjectDecoder.State getDecoderState()  
      protected boolean isContentAlwaysEmpty​(io.netty.handler.codec.http.HttpMessage msg)  
      protected abstract boolean isDecodingRequest()  
      protected boolean isSwitchingToNonHttp1Protocol​(io.netty.handler.codec.http.HttpResponse msg)
      Returns true if the server switched to a different protocol than HTTP/1.0 or HTTP/1.1, e.g.
      void reset()
      Resets the state of the decoder so that it is ready to decode a new message.
      void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx, java.lang.Object evt)  
      • Methods inherited from class io.netty.handler.codec.http.HttpObjectDecoder

        handleTransferEncodingChunkedWithContentLength
      • Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder

        actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode
      • Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

        channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
      • Methods inherited from class io.netty.channel.ChannelHandlerAdapter

        ensureNotSharable, handlerAdded, 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

        handlerAdded
    • Field Detail

      • validateHeaders

        protected final boolean validateHeaders
    • Constructor Detail

      • BasicHttpObjectDecoder

        protected BasicHttpObjectDecoder()
        Creates a new instance with the default maxInitialLineLength (4096}, maxHeaderSize (8192), and maxChunkSize (8192).
      • BasicHttpObjectDecoder

        protected BasicHttpObjectDecoder​(int maxInitialLineLength,
                                         int maxHeaderSize,
                                         int maxChunkSize,
                                         boolean chunkedSupported)
        Creates a new instance with the specified parameters.
      • BasicHttpObjectDecoder

        protected BasicHttpObjectDecoder​(int maxInitialLineLength,
                                         int maxHeaderSize,
                                         int maxChunkSize,
                                         boolean chunkedSupported,
                                         boolean validateHeaders)
        Creates a new instance with the specified parameters.
      • BasicHttpObjectDecoder

        protected BasicHttpObjectDecoder​(int maxInitialLineLength,
                                         int maxHeaderSize,
                                         int maxChunkSize,
                                         boolean chunkedSupported,
                                         boolean validateHeaders,
                                         int initialBufferSize)
    • Method Detail

      • decode

        protected void decode​(io.netty.channel.ChannelHandlerContext ctx,
                              io.netty.buffer.ByteBuf buffer,
                              java.util.List<java.lang.Object> out)
                       throws java.lang.Exception
        Overrides:
        decode in class io.netty.handler.codec.http.HttpObjectDecoder
        Throws:
        java.lang.Exception
      • decodeLast

        protected void decodeLast​(io.netty.channel.ChannelHandlerContext ctx,
                                  io.netty.buffer.ByteBuf in,
                                  java.util.List<java.lang.Object> out)
                           throws java.lang.Exception
        Overrides:
        decodeLast in class io.netty.handler.codec.http.HttpObjectDecoder
        Throws:
        java.lang.Exception
      • userEventTriggered

        public void userEventTriggered​(io.netty.channel.ChannelHandlerContext ctx,
                                       java.lang.Object evt)
                                throws java.lang.Exception
        Specified by:
        userEventTriggered in interface io.netty.channel.ChannelInboundHandler
        Overrides:
        userEventTriggered in class io.netty.handler.codec.http.HttpObjectDecoder
        Throws:
        java.lang.Exception
      • isContentAlwaysEmpty

        protected boolean isContentAlwaysEmpty​(io.netty.handler.codec.http.HttpMessage msg)
        Overrides:
        isContentAlwaysEmpty in class io.netty.handler.codec.http.HttpObjectDecoder
      • isSwitchingToNonHttp1Protocol

        protected boolean isSwitchingToNonHttp1Protocol​(io.netty.handler.codec.http.HttpResponse msg)
        Returns true if the server switched to a different protocol than HTTP/1.0 or HTTP/1.1, e.g. HTTP/2 or Websocket. Returns false if the upgrade happened in a different layer, e.g. upgrade from HTTP/1.1 to HTTP/1.1 over TLS.
        Overrides:
        isSwitchingToNonHttp1Protocol in class io.netty.handler.codec.http.HttpObjectDecoder
      • reset

        public void reset()
        Resets the state of the decoder so that it is ready to decode a new message. This method is useful for handling a rejected request with Expect: 100-continue header.
        Overrides:
        reset in class io.netty.handler.codec.http.HttpObjectDecoder
      • isDecodingRequest

        protected abstract boolean isDecodingRequest()
        Specified by:
        isDecodingRequest in class io.netty.handler.codec.http.HttpObjectDecoder
      • createMessage

        protected io.netty.handler.codec.http.HttpMessage createMessage​(ByteBufAsciiString[] initialLine)
                                                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • createMessage

        protected abstract io.netty.handler.codec.http.HttpMessage createMessage​(java.lang.String[] initialLine)
                                                                          throws java.lang.Exception
        Specified by:
        createMessage in class io.netty.handler.codec.http.HttpObjectDecoder
        Throws:
        java.lang.Exception
      • createInvalidMessage

        protected abstract io.netty.handler.codec.http.HttpMessage createInvalidMessage()
        Specified by:
        createInvalidMessage in class io.netty.handler.codec.http.HttpObjectDecoder