Class SpdyFrameCodec
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.ByteToMessageDecoder
io.netty.handler.codec.spdy.SpdyFrameCodec
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler, SpdyFrameDecoderDelegate
public class SpdyFrameCodec
extends ByteToMessageDecoder
implements SpdyFrameDecoderDelegate, ChannelOutboundHandler
A
ChannelHandler that encodes and decodes SPDY Frames.-
Nested Class Summary
Nested classes/interfaces inherited from class ByteToMessageDecoder
ByteToMessageDecoder.CumulatorNested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final SpdyProtocolExceptionprotected final SpdyFrameDecoderprotected final SpdyFrameEncoderFields inherited from class ByteToMessageDecoder
COMPOSITE_CUMULATOR, MERGE_CUMULATOR -
Constructor Summary
ConstructorsModifierConstructorDescriptionSpdyFrameCodec(SpdyVersion version) Creates a new instance with the specifiedversion,validateHeaders (true), and the default decoder and encoder options (maxChunkSize (8192),maxHeaderSize (16384),compressionLevel (6),windowBits (15), andmemLevel (8)).SpdyFrameCodec(SpdyVersion version, boolean validateHeaders) Creates a new instance with the specifiedversion,validateHeaders, and the default decoder and encoder options (maxChunkSize (8192),maxHeaderSize (16384),compressionLevel (6),windowBits (15), andmemLevel (8)).SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel) Creates a new instance with the specifiedversion,validateHeaders (true), decoder and encoder options.SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel, boolean validateHeaders) Creates a new instance with the specifiedversion,validateHeaders, decoder and encoder options.SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel, boolean validateHeaders, boolean supportsUnknownFrames) Creates a new instance with the specifiedversion,validateHeaders, decoder and encoder options.protectedSpdyFrameCodec(SpdyVersion version, int maxChunkSize, SpdyHeaderBlockDecoder spdyHeaderBlockDecoder, SpdyHeaderBlockEncoder spdyHeaderBlockEncoder, boolean validateHeaders) protectedSpdyFrameCodec(SpdyVersion version, int maxChunkSize, SpdyHeaderBlockDecoder spdyHeaderBlockDecoder, SpdyHeaderBlockEncoder spdyHeaderBlockEncoder, boolean validateHeaders, boolean supportsUnknownFrames) -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) Called once a bind operation is made.voidCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidclose(ChannelHandlerContext ctx, ChannelPromise promise) Called once a close operation is made.voidconnect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) Called once a connect operation is made.protected SpdyFrameDecodercreateDecoder(SpdyVersion version, SpdyFrameDecoderDelegate delegate, int maxChunkSize) protected SpdyFrameEncodercreateEncoder(SpdyVersion version) protected voiddecode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Decode the from oneByteBufto an other.voidderegister(ChannelHandlerContext ctx, ChannelPromise promise) Called once a deregister operation is made from the current registeredEventLoop.voiddisconnect(ChannelHandlerContext ctx, ChannelPromise promise) Called once a disconnect operation is made.voidflush(ChannelHandlerContext ctx) Called once a flush operation is made.voidDo nothing by default, sub-classes may override this method.protected booleanisValidUnknownFrameHeader(int streamId, int type, byte flags, int length) Check whether the unknown frame is valid, if not, the frame will be discarded, otherwise, the frame will be passed toSpdyFrameDecoder.decodeUnknownFrame(int, byte, int, ByteBuf).protected SpdyFramenewSpdyUnknownFrame(int frameType, byte flags, ByteBuf payload) Create a SpdyUnknownFrame.voidread(ChannelHandlerContext ctx) InterceptsChannelHandlerContext.read().voidreadDataFrame(int streamId, boolean last, ByteBuf data) Called when a DATA frame is received.voidreadFrameError(String message) Called when an unrecoverable session error has occurred.voidreadGoAwayFrame(int lastGoodStreamId, int statusCode) Called when a GOAWAY frame is received.voidreadHeaderBlock(ByteBuf headerBlock) Called when the header block within a SYN_STREAM, SYN_REPLY, or HEADERS frame is received.voidCalled when an entire header block has been received.voidreadHeadersFrame(int streamId, boolean last) Called when a HEADERS frame is received.voidreadPingFrame(int id) Called when a PING frame is received.voidreadRstStreamFrame(int streamId, int statusCode) Called when a RST_STREAM frame is received.voidreadSetting(int id, int value, boolean persistValue, boolean persisted) Called when an individual setting within a SETTINGS frame is received.voidCalled when the entire SETTINGS frame has been received.voidreadSettingsFrame(boolean clearPersisted) Called when a SETTINGS frame is received.voidreadSynReplyFrame(int streamId, boolean last) Called when a SYN_REPLY frame is received.voidreadSynStreamFrame(int streamId, int associatedToStreamId, byte priority, boolean last, boolean unidirectional) Called when a SYN_STREAM frame is received.voidreadUnknownFrame(int frameType, byte flags, ByteBuf payload) Called when an unknown frame is received.voidreadWindowUpdateFrame(int streamId, int deltaWindowSize) Called when a WINDOW_UPDATE frame is received.voidwrite(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) Called once a write operation is made.Methods inherited from class ByteToMessageDecoder
actualReadableBytes, callDecode, channelInactive, channelRead, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggeredMethods inherited from class ChannelInboundHandlerAdapter
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaughtMethods inherited from class ChannelHandlerAdapter
ensureNotSharable, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChannelHandler
handlerRemoved
-
Field Details
-
INVALID_FRAME
-
spdyFrameDecoder
-
spdyFrameEncoder
-
-
Constructor Details
-
SpdyFrameCodec
Creates a new instance with the specifiedversion,validateHeaders (true), and the default decoder and encoder options (maxChunkSize (8192),maxHeaderSize (16384),compressionLevel (6),windowBits (15), andmemLevel (8)). -
SpdyFrameCodec
Creates a new instance with the specifiedversion,validateHeaders, and the default decoder and encoder options (maxChunkSize (8192),maxHeaderSize (16384),compressionLevel (6),windowBits (15), andmemLevel (8)). -
SpdyFrameCodec
public SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel) Creates a new instance with the specifiedversion,validateHeaders (true), decoder and encoder options. -
SpdyFrameCodec
public SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel, boolean validateHeaders) Creates a new instance with the specifiedversion,validateHeaders, decoder and encoder options. -
SpdyFrameCodec
public SpdyFrameCodec(SpdyVersion version, int maxChunkSize, int maxHeaderSize, int compressionLevel, int windowBits, int memLevel, boolean validateHeaders, boolean supportsUnknownFrames) Creates a new instance with the specifiedversion,validateHeaders, decoder and encoder options. -
SpdyFrameCodec
protected SpdyFrameCodec(SpdyVersion version, int maxChunkSize, SpdyHeaderBlockDecoder spdyHeaderBlockDecoder, SpdyHeaderBlockEncoder spdyHeaderBlockEncoder, boolean validateHeaders) -
SpdyFrameCodec
protected SpdyFrameCodec(SpdyVersion version, int maxChunkSize, SpdyHeaderBlockDecoder spdyHeaderBlockDecoder, SpdyHeaderBlockEncoder spdyHeaderBlockEncoder, boolean validateHeaders, boolean supportsUnknownFrames)
-
-
Method Details
-
createDecoder
protected SpdyFrameDecoder createDecoder(SpdyVersion version, SpdyFrameDecoderDelegate delegate, int maxChunkSize) -
createEncoder
-
handlerAdded
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter- Throws:
Exception
-
decode
Description copied from class:ByteToMessageDecoderDecode the from oneByteBufto an other. This method will be called till either the inputByteBufhas nothing to read when return from this method or till nothing was read from the inputByteBuf.- Specified by:
decodein classByteToMessageDecoder- Parameters:
ctx- theChannelHandlerContextwhich thisByteToMessageDecoderbelongs toin- theByteBuffrom which to read dataout- theListto which decoded messages should be added- Throws:
Exception- is thrown if an error occurs
-
channelReadComplete
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelReadCompletein interfaceChannelInboundHandler- Overrides:
channelReadCompletein classByteToMessageDecoder- Throws:
Exception
-
bind
public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception Description copied from interface:ChannelOutboundHandlerCalled once a bind operation is made.- Specified by:
bindin interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the bind operation is madelocalAddress- theSocketAddressto which it should boundpromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
connect
public void connect(ChannelHandlerContext ctx, SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception Description copied from interface:ChannelOutboundHandlerCalled once a connect operation is made.- Specified by:
connectin interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the connect operation is maderemoteAddress- theSocketAddressto which it should connectlocalAddress- theSocketAddresswhich is used as source on connectpromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
disconnect
Description copied from interface:ChannelOutboundHandlerCalled once a disconnect operation is made.- Specified by:
disconnectin interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the disconnect operation is madepromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
close
Description copied from interface:ChannelOutboundHandlerCalled once a close operation is made.- Specified by:
closein interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the close operation is madepromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
deregister
Description copied from interface:ChannelOutboundHandlerCalled once a deregister operation is made from the current registeredEventLoop.- Specified by:
deregisterin interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the close operation is madepromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
read
Description copied from interface:ChannelOutboundHandlerInterceptsChannelHandlerContext.read().- Specified by:
readin interfaceChannelOutboundHandler- Throws:
Exception
-
flush
Description copied from interface:ChannelOutboundHandlerCalled once a flush operation is made. The flush operation will try to flush out all previous written messages that are pending.- Specified by:
flushin interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the flush operation is made- Throws:
Exception- thrown if an error occurs
-
write
Description copied from interface:ChannelOutboundHandlerCalled once a write operation is made. The write operation will write the messages through theChannelPipeline. Those are then ready to be flushed to the actualChannelonceChannel.flush()is called- Specified by:
writein interfaceChannelOutboundHandler- Parameters:
ctx- theChannelHandlerContextfor which the write operation is mademsg- the message to writepromise- theChannelPromiseto notify once the operation completes- Throws:
Exception- thrown if an error occurs
-
readDataFrame
Description copied from interface:SpdyFrameDecoderDelegateCalled when a DATA frame is received.- Specified by:
readDataFramein interfaceSpdyFrameDecoderDelegate
-
readSynStreamFrame
public void readSynStreamFrame(int streamId, int associatedToStreamId, byte priority, boolean last, boolean unidirectional) Description copied from interface:SpdyFrameDecoderDelegateCalled when a SYN_STREAM frame is received. The Name/Value Header Block is not included. See readHeaderBlock().- Specified by:
readSynStreamFramein interfaceSpdyFrameDecoderDelegate
-
readSynReplyFrame
public void readSynReplyFrame(int streamId, boolean last) Description copied from interface:SpdyFrameDecoderDelegateCalled when a SYN_REPLY frame is received. The Name/Value Header Block is not included. See readHeaderBlock().- Specified by:
readSynReplyFramein interfaceSpdyFrameDecoderDelegate
-
readRstStreamFrame
public void readRstStreamFrame(int streamId, int statusCode) Description copied from interface:SpdyFrameDecoderDelegateCalled when a RST_STREAM frame is received.- Specified by:
readRstStreamFramein interfaceSpdyFrameDecoderDelegate
-
readSettingsFrame
public void readSettingsFrame(boolean clearPersisted) Description copied from interface:SpdyFrameDecoderDelegateCalled when a SETTINGS frame is received. Settings are not included. See readSetting().- Specified by:
readSettingsFramein interfaceSpdyFrameDecoderDelegate
-
readSetting
public void readSetting(int id, int value, boolean persistValue, boolean persisted) Description copied from interface:SpdyFrameDecoderDelegateCalled when an individual setting within a SETTINGS frame is received.- Specified by:
readSettingin interfaceSpdyFrameDecoderDelegate
-
readSettingsEnd
public void readSettingsEnd()Description copied from interface:SpdyFrameDecoderDelegateCalled when the entire SETTINGS frame has been received.- Specified by:
readSettingsEndin interfaceSpdyFrameDecoderDelegate
-
readPingFrame
public void readPingFrame(int id) Description copied from interface:SpdyFrameDecoderDelegateCalled when a PING frame is received.- Specified by:
readPingFramein interfaceSpdyFrameDecoderDelegate
-
readGoAwayFrame
public void readGoAwayFrame(int lastGoodStreamId, int statusCode) Description copied from interface:SpdyFrameDecoderDelegateCalled when a GOAWAY frame is received.- Specified by:
readGoAwayFramein interfaceSpdyFrameDecoderDelegate
-
readHeadersFrame
public void readHeadersFrame(int streamId, boolean last) Description copied from interface:SpdyFrameDecoderDelegateCalled when a HEADERS frame is received. The Name/Value Header Block is not included. See readHeaderBlock().- Specified by:
readHeadersFramein interfaceSpdyFrameDecoderDelegate
-
readWindowUpdateFrame
public void readWindowUpdateFrame(int streamId, int deltaWindowSize) Description copied from interface:SpdyFrameDecoderDelegateCalled when a WINDOW_UPDATE frame is received.- Specified by:
readWindowUpdateFramein interfaceSpdyFrameDecoderDelegate
-
readHeaderBlock
Description copied from interface:SpdyFrameDecoderDelegateCalled when the header block within a SYN_STREAM, SYN_REPLY, or HEADERS frame is received.- Specified by:
readHeaderBlockin interfaceSpdyFrameDecoderDelegate
-
readHeaderBlockEnd
public void readHeaderBlockEnd()Description copied from interface:SpdyFrameDecoderDelegateCalled when an entire header block has been received.- Specified by:
readHeaderBlockEndin interfaceSpdyFrameDecoderDelegate
-
readUnknownFrame
Description copied from interface:SpdyFrameDecoderDelegateCalled when an unknown frame is received.- Specified by:
readUnknownFramein interfaceSpdyFrameDecoderDelegate- Parameters:
frameType- the frame type from the spdy header.flags- the flags in the frame header.payload- the payload of the frame.
-
newSpdyUnknownFrame
-
isValidUnknownFrameHeader
protected boolean isValidUnknownFrameHeader(int streamId, int type, byte flags, int length) Check whether the unknown frame is valid, if not, the frame will be discarded, otherwise, the frame will be passed toSpdyFrameDecoder.decodeUnknownFrame(int, byte, int, ByteBuf).By default this method always returns
false, sub-classes may override this. -
readFrameError
Description copied from interface:SpdyFrameDecoderDelegateCalled when an unrecoverable session error has occurred.- Specified by:
readFrameErrorin interfaceSpdyFrameDecoderDelegate
-