GeezerVison is showing netty.io — LineBasedFrameDecoder (Netty API Reference (4.1.141.Final))
Class LineBasedFrameDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
- Direct Known Subclasses:
SmtpResponseDecoder
A decoder that splits the received ByteBufs on line endings.
Both "\n" and "\r\n" are handled.
The byte stream is expected to be in UTF-8 character encoding or ASCII. The current implementation
uses direct byte to char cast and then compares that char to a few low range
ASCII characters like '\n' or '\r'. UTF-8 is not using low range [0..0x7F]
byte values for multibyte codepoint representations therefore fully supported by this implementation.
For a more general delimiter-based decoder, see DelimiterBasedFrameDecoder.
Users should be aware that used as is, the lenient approach on lone '\n might result on a parser
diffenrencial on line based protocols requiring the use of "\r\n" delimiters like SMTP and can
result in attacks similar to
SMTP smuggling.
Validating afterward the end of line pattern can be a possible mitigation.
-
-
-
Constructor Summary
Constructors
-
Method Summary
Modifier and Type
Method
Description
Create a frame out of the ByteBuf and return it.
protected final void
Decode the from one ByteBuf to an other.
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
Modifier and Type
Method
Description
protected int
Returns the actual number of readable bytes in the internal cumulative
buffer of this decoder.
protected void
Called once data should be decoded from the given ByteBuf.
void
void
void
protected void
protected final void
final void
Do nothing by default, sub-classes may override this method.
protected void
Gets called after the ByteToMessageDecoder was removed from the actual context and it doesn't handle
events anymore.
Returns the internal cumulative buffer of this decoder.
boolean
void
void
void
void
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
LineBasedFrameDecoder
public LineBasedFrameDecoder(int maxLength)
Creates a new decoder.
- Parameters:
maxLength - the maximum length of the decoded frame.
A TooLongFrameException is thrown if
the length of the frame exceeds this value.
-
LineBasedFrameDecoder
public LineBasedFrameDecoder(int maxLength,
boolean stripDelimiter,
boolean failFast)
Creates a new decoder.
- Parameters:
maxLength - the maximum length of the decoded frame.
A TooLongFrameException is thrown if
the length of the frame exceeds this value.
stripDelimiter - whether the decoded frame should strip out the
delimiter or not
failFast - If true, a TooLongFrameException is
thrown as soon as the decoder notices the length of the
frame will exceed maxFrameLength regardless of
whether the entire frame has been read.
If false, a TooLongFrameException is
thrown after the entire frame that exceeds
maxFrameLength has been read.
-
|