Package io.netty.handler.codec.spdy
Class SpdyHttpDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageDecoder<SpdyFrame>
-
- io.netty.handler.codec.spdy.SpdyHttpDecoder
-
- All Implemented Interfaces:
ChannelHandler,ChannelInboundHandler
public class SpdyHttpDecoder extends MessageToMessageDecoder<SpdyFrame>
DecodesSpdySynStreamFrames,SpdySynReplyFrames, andSpdyDataFrames intoFullHttpRequests andFullHttpResponses.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
-
Field Summary
Fields Modifier and Type Field Description private intmaxContentLengthprivate java.util.Map<java.lang.Integer,FullHttpMessage>messageMapprivate intspdyVersionprivate booleanvalidateHeaders
-
Constructor Summary
Constructors Modifier Constructor Description SpdyHttpDecoder(SpdyVersion version, int maxContentLength)Creates a new instance.SpdyHttpDecoder(SpdyVersion version, int maxContentLength, boolean validateHeaders)Creates a new instance.protectedSpdyHttpDecoder(SpdyVersion version, int maxContentLength, java.util.Map<java.lang.Integer,FullHttpMessage> messageMap)Creates a new instance with the specified parameters.protectedSpdyHttpDecoder(SpdyVersion version, int maxContentLength, java.util.Map<java.lang.Integer,FullHttpMessage> messageMap, boolean validateHeaders)Creates a new instance with the specified parameters.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchannelInactive(ChannelHandlerContext ctx)CallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.private static FullHttpRequestcreateHttpRequest(SpdyHeadersFrame requestFrame, ByteBufAllocator alloc)private static FullHttpResponsecreateHttpResponse(SpdyHeadersFrame responseFrame, ByteBufAllocator alloc, boolean validateHeaders)protected voiddecode(ChannelHandlerContext ctx, SpdyFrame msg, java.util.List<java.lang.Object> out)Decode from one message to an other.protected FullHttpMessagegetMessage(int streamId)protected FullHttpMessageputMessage(int streamId, FullHttpMessage message)protected FullHttpMessageremoveMessage(int streamId)-
Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder
acceptInboundMessage, channelRead
-
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
-
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
-
-
-
Field Detail
-
validateHeaders
private final boolean validateHeaders
-
spdyVersion
private final int spdyVersion
-
maxContentLength
private final int maxContentLength
-
messageMap
private final java.util.Map<java.lang.Integer,FullHttpMessage> messageMap
-
-
Constructor Detail
-
SpdyHttpDecoder
public SpdyHttpDecoder(SpdyVersion version, int maxContentLength)
Creates a new instance.- Parameters:
version- the protocol versionmaxContentLength- the maximum length of the message content. If the length of the message content exceeds this value, aTooLongFrameExceptionwill be raised.
-
SpdyHttpDecoder
public SpdyHttpDecoder(SpdyVersion version, int maxContentLength, boolean validateHeaders)
Creates a new instance.- Parameters:
version- the protocol versionmaxContentLength- the maximum length of the message content. If the length of the message content exceeds this value, aTooLongFrameExceptionwill be raised.validateHeaders-trueif http headers should be validated
-
SpdyHttpDecoder
protected SpdyHttpDecoder(SpdyVersion version, int maxContentLength, java.util.Map<java.lang.Integer,FullHttpMessage> messageMap)
Creates a new instance with the specified parameters.- Parameters:
version- the protocol versionmaxContentLength- the maximum length of the message content. If the length of the message content exceeds this value, aTooLongFrameExceptionwill be raised.messageMap- theMapused to hold partially received messages.
-
SpdyHttpDecoder
protected SpdyHttpDecoder(SpdyVersion version, int maxContentLength, java.util.Map<java.lang.Integer,FullHttpMessage> messageMap, boolean validateHeaders)
Creates a new instance with the specified parameters.- Parameters:
version- the protocol versionmaxContentLength- the maximum length of the message content. If the length of the message content exceeds this value, aTooLongFrameExceptionwill be raised.messageMap- theMapused to hold partially received messages.validateHeaders-trueif http headers should be validated
-
-
Method Detail
-
channelInactive
public void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelInactivein interfaceChannelInboundHandler- Overrides:
channelInactivein classChannelInboundHandlerAdapter- Throws:
java.lang.Exception
-
putMessage
protected FullHttpMessage putMessage(int streamId, FullHttpMessage message)
-
getMessage
protected FullHttpMessage getMessage(int streamId)
-
removeMessage
protected FullHttpMessage removeMessage(int streamId)
-
decode
protected void decode(ChannelHandlerContext ctx, SpdyFrame msg, java.util.List<java.lang.Object> out) throws java.lang.Exception
Description copied from class:MessageToMessageDecoderDecode from one message to an other. This method will be called for each written message that can be handled by this decoder.- Specified by:
decodein classMessageToMessageDecoder<SpdyFrame>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToMessageDecoderbelongs tomsg- the message to decode to an other oneout- theListto which decoded messages should be added- Throws:
java.lang.Exception- is thrown if an error occurs
-
createHttpRequest
private static FullHttpRequest createHttpRequest(SpdyHeadersFrame requestFrame, ByteBufAllocator alloc) throws java.lang.Exception
- Throws:
java.lang.Exception
-
createHttpResponse
private static FullHttpResponse createHttpResponse(SpdyHeadersFrame responseFrame, ByteBufAllocator alloc, boolean validateHeaders) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-