Class HAProxyMessageDecoder.HeaderExtractor

java.lang.Object
io.netty.handler.codec.haproxy.HAProxyMessageDecoder.HeaderExtractor
Direct Known Subclasses:
HAProxyMessageDecoder.LineHeaderExtractor, HAProxyMessageDecoder.StructHeaderExtractor
Enclosing class:
HAProxyMessageDecoder

private abstract class HAProxyMessageDecoder.HeaderExtractor extends Object
HeaderExtractor create a header frame out of the ByteBuf.
  • Field Details

    • maxHeaderSize

      private final int maxHeaderSize
      Header max size
  • Constructor Details

    • HeaderExtractor

      protected HeaderExtractor(int maxHeaderSize)
  • Method Details

    • extract

      public ByteBuf extract(ChannelHandlerContext ctx, ByteBuf buffer) throws Exception
      Create a frame out of the ByteBuf and return it.
      Parameters:
      ctx - the ChannelHandlerContext which this HAProxyMessageDecoder belongs to
      buffer - the ByteBuf from which to read data
      Returns:
      frame the ByteBuf which represent the frame or null if no frame could be created
      Throws:
      Exception - if exceed maxLength
    • findEndOfHeader

      protected abstract int findEndOfHeader(ByteBuf buffer)
      Find the end of the header from the given ByteBuf,the end may be a CRLF, or the length given by the header.
      Parameters:
      buffer - the buffer to be searched
      Returns:
      -1 if can not find the end, otherwise return the buffer index of end
    • delimiterLength

      protected abstract int delimiterLength(ByteBuf buffer, int eoh)
      Get the length of the header delimiter.
      Parameters:
      buffer - the buffer where delimiter is located
      eoh - index of delimiter
      Returns:
      length of the delimiter