Package org.mockserver.netty.proxy
Class BinaryMessageFramer
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
org.mockserver.netty.proxy.BinaryMessageFramer
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
LengthPrefixMessageFramer,MysqlMessageFramer,PostgresqlMessageFramer,RedisMessageFramer
public abstract class BinaryMessageFramer
extends io.netty.handler.codec.ByteToMessageDecoder
Cuts a binary connection into the messages of a protocol, as a client sends them, so that each is matched,
forwarded and logged as one message however it was read. One per connection, in front of
BinaryRequestProxyingHandler, in place of BinaryMessageGatherer.
At most maxMessageBytes are held: a connection that declares a longer message, or sends bytes the protocol
does not allow, is closed and the rest of what it sends is dropped. The part of a message held when the connection
closes is released with the cumulation.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final longWhatmessageBytes(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf)answers while the bytes held cannot yet say how long the message is.Fields inherited from class io.netty.handler.codec.ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBinaryMessageFramer(int maxMessageBytes, org.mockserver.logging.MockServerLogger mockServerLogger, String framing) -
Method Summary
Modifier and TypeMethodDescriptionbooleanTrue when no part of a message is held: what is read next starts a message.intbytesBeforeTlsMayStart(io.netty.buffer.ByteBuf in, int available) How many of theavailablebytes fromin's reader index, read in the clear, end a message after which a client may start a TLS handshake without waiting for a reply, when more bytes follow; otherwise 0.protected final voidstatic BinaryMessageFramerforConfiguration(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger) The framer binaryMessageFraming names, or null for RAW.protected intprotected abstract longmessageBytes(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in) How many bytes the message that starts at the reader index has,NOT_YET_KNOWNwhile the bytes held cannot say, or anything afterrefuse(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.lang.String).protected voidmessageTaken(io.netty.buffer.ByteBuf message) Called with each whole message before it is passed on.protected booleanprotected final voidbooleanWhether a TLS handshake may begin with the next byte read: only at a message boundary, and only where the protocol lets one begin.Methods inherited from class io.netty.handler.codec.ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded
-
Field Details
-
NOT_YET_KNOWN
protected static final long NOT_YET_KNOWNWhatmessageBytes(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf)answers while the bytes held cannot yet say how long the message is.- See Also:
-
-
Constructor Details
-
BinaryMessageFramer
protected BinaryMessageFramer(int maxMessageBytes, org.mockserver.logging.MockServerLogger mockServerLogger, String framing)
-
-
Method Details
-
forConfiguration
public static BinaryMessageFramer forConfiguration(org.mockserver.configuration.Configuration configuration, org.mockserver.logging.MockServerLogger mockServerLogger) The framer binaryMessageFraming names, or null for RAW. -
maxMessageBytes
protected int maxMessageBytes() -
atMessageBoundary
public boolean atMessageBoundary()True when no part of a message is held: what is read next starts a message. Anything else is the middle of one, whatever its bytes look like. -
tlsMayStartHere
public boolean tlsMayStartHere()Whether a TLS handshake may begin with the next byte read: only at a message boundary, and only where the protocol lets one begin. -
protocolAllowsTlsHere
protected boolean protocolAllowsTlsHere() -
bytesBeforeTlsMayStart
public int bytesBeforeTlsMayStart(io.netty.buffer.ByteBuf in, int available) How many of theavailablebytes fromin's reader index, read in the clear, end a message after which a client may start a TLS handshake without waiting for a reply, when more bytes follow; otherwise 0. -
messageBytes
protected abstract long messageBytes(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in) How many bytes the message that starts at the reader index has,NOT_YET_KNOWNwhile the bytes held cannot say, or anything afterrefuse(io.netty.channel.ChannelHandlerContext, io.netty.buffer.ByteBuf, java.lang.String). Must not move the reader index. -
messageTaken
protected void messageTaken(io.netty.buffer.ByteBuf message) Called with each whole message before it is passed on. -
decode
protected final void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, List<Object> out) - Specified by:
decodein classio.netty.handler.codec.ByteToMessageDecoder
-
refuse
protected final void refuse(io.netty.channel.ChannelHandlerContext ctx, io.netty.buffer.ByteBuf in, String declared)
-