Package io.netty.handler.codec.http2
Class Http2ConnectionHandler.PrefaceDecoder
- java.lang.Object
-
- io.netty.handler.codec.http2.Http2ConnectionHandler.BaseDecoder
-
- io.netty.handler.codec.http2.Http2ConnectionHandler.PrefaceDecoder
-
- Enclosing class:
- Http2ConnectionHandler
private final class Http2ConnectionHandler.PrefaceDecoder extends Http2ConnectionHandler.BaseDecoder
-
-
Field Summary
Fields Modifier and Type Field Description private ByteBuf
clientPrefaceString
private boolean
prefaceSent
-
Constructor Summary
Constructors Constructor Description PrefaceDecoder(ChannelHandlerContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelActive(ChannelHandlerContext ctx)
void
channelInactive(ChannelHandlerContext ctx)
private void
cleanup()
Releases theclientPrefaceString
.void
decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out)
void
handlerRemoved(ChannelHandlerContext ctx)
Releases theclientPrefaceString
.boolean
prefaceSent()
Determine if the HTTP/2 connection preface been sent.private boolean
readClientPrefaceString(ByteBuf in)
Decodes the client connection preface string from the input buffer.private void
sendPreface(ChannelHandlerContext ctx)
Sends the HTTP/2 connection preface upon establishment of the connection, if not already sent.private boolean
verifyFirstFrameIsSettings(ByteBuf in)
Peeks at that the next frame in the buffer and verifies that it is a non-ackSETTINGS
frame.
-
-
-
Field Detail
-
clientPrefaceString
private ByteBuf clientPrefaceString
-
prefaceSent
private boolean prefaceSent
-
-
Constructor Detail
-
PrefaceDecoder
PrefaceDecoder(ChannelHandlerContext ctx) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-
Method Detail
-
prefaceSent
public boolean prefaceSent()
Description copied from class:Http2ConnectionHandler.BaseDecoder
Determine if the HTTP/2 connection preface been sent.- Overrides:
prefaceSent
in classHttp2ConnectionHandler.BaseDecoder
-
decode
public void decode(ChannelHandlerContext ctx, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
- Specified by:
decode
in classHttp2ConnectionHandler.BaseDecoder
- Throws:
java.lang.Exception
-
channelActive
public void channelActive(ChannelHandlerContext ctx) throws java.lang.Exception
- Overrides:
channelActive
in classHttp2ConnectionHandler.BaseDecoder
- Throws:
java.lang.Exception
-
channelInactive
public void channelInactive(ChannelHandlerContext ctx) throws java.lang.Exception
- Overrides:
channelInactive
in classHttp2ConnectionHandler.BaseDecoder
- Throws:
java.lang.Exception
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws java.lang.Exception
Releases theclientPrefaceString
. Any active streams will be left in the open.- Overrides:
handlerRemoved
in classHttp2ConnectionHandler.BaseDecoder
- Throws:
java.lang.Exception
-
cleanup
private void cleanup()
Releases theclientPrefaceString
. Any active streams will be left in the open.
-
readClientPrefaceString
private boolean readClientPrefaceString(ByteBuf in) throws Http2Exception
Decodes the client connection preface string from the input buffer.- Returns:
true
if processing of the client preface string is complete. Since client preface strings can only be received by servers, returns true immediately for client endpoints.- Throws:
Http2Exception
-
verifyFirstFrameIsSettings
private boolean verifyFirstFrameIsSettings(ByteBuf in) throws Http2Exception
Peeks at that the next frame in the buffer and verifies that it is a non-ackSETTINGS
frame.- Parameters:
in
- the inbound buffer.- Returns:
true
if the next frame is a non-ackSETTINGS
frame,false
if more data is required before we can determine the next frame type.- Throws:
Http2Exception
- thrown if the next frame is NOT a non-ackSETTINGS
frame.
-
sendPreface
private void sendPreface(ChannelHandlerContext ctx) throws java.lang.Exception
Sends the HTTP/2 connection preface upon establishment of the connection, if not already sent.- Throws:
java.lang.Exception
-
-