Package com.wavefront.agent.channel
Class PlainTextOrHttpFrameDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.ByteToMessageDecoder
-
- com.wavefront.agent.channel.PlainTextOrHttpFrameDecoder
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
public final class PlainTextOrHttpFrameDecoder extends io.netty.handler.codec.ByteToMessageDecoder
This class handles 2 different protocols on a single port. Supported protocols include HTTP and a plain text protocol. It dynamically adds the appropriate encoder/decoder based on the detected protocol. This class was largely adapted from the example provided with netty v4.0- Author:
- Mike McLaughlin ([email protected])
- See Also:
- Netty Port Unification Example
-
-
Constructor Summary
Constructors Constructor Description PlainTextOrHttpFrameDecoder(io.netty.channel.ChannelHandler handler, io.netty.handler.codec.http.cors.CorsConfig corsConfig, int maxLengthPlaintext, int maxLengthHttp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf buffer, List<Object> out)
Dynamically adds the appropriate encoder/decoder(s) to the pipeline based on the detected protocol.-
Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
-
-
-
Field Detail
-
logger
protected static final Logger logger
-
-
Constructor Detail
-
PlainTextOrHttpFrameDecoder
public PlainTextOrHttpFrameDecoder(io.netty.channel.ChannelHandler handler, @Nullable io.netty.handler.codec.http.cors.CorsConfig corsConfig, int maxLengthPlaintext, int maxLengthHttp)
- Parameters:
handler
- the object responsible for handling the incoming messages on either protocol.corsConfig
- enables CORS whenCorsConfig
is specifiedmaxLengthPlaintext
- max allowed line length for line-delimiter protocolmaxLengthHttp
- max allowed size for incoming HTTP requests
-
-