Package io.netty.handler.codec.http2
Class DefaultHttp2ConnectionDecoder
java.lang.Object
io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder
- All Implemented Interfaces:
Http2ConnectionDecoder
,Closeable
,AutoCloseable
Provides the default implementation for processing inbound frame events and delegates to a
Http2FrameListener
This class will read HTTP/2 frames and delegate the events to a Http2FrameListener
This interface enforces inbound flow control functionality through
Http2LocalFlowController
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
private final class
Handles all inbound frames from the network.private final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private final Http2Connection
private final Http2Connection.PropertyKey
private final Http2ConnectionEncoder
private final Http2FrameReader
private Http2FrameListener
private Http2LifecycleManager
private Http2FrameListener
private static final InternalLogger
private final Http2PromisedRequestVerifier
private final Http2SettingsReceivedConsumer
private final boolean
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultHttp2ConnectionDecoder
(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader) DefaultHttp2ConnectionDecoder
(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier) DefaultHttp2ConnectionDecoder
(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier, boolean autoAckSettings) Create a new instance.DefaultHttp2ConnectionDecoder
(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier, boolean autoAckSettings, boolean autoAckPing) Deprecated.DefaultHttp2ConnectionDecoder
(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier, boolean autoAckSettings, boolean autoAckPing, boolean validateHeaders) Create a new instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected long
calculateMaxHeaderListSizeGoAway
(long maxHeaderListSize) Calculate the threshold in bytes which should trigger aGO_AWAY
if a set of headers exceeds this amount.void
close()
Provides direct access to the underlying connection.void
decodeFrame
(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) Called by theHttp2ConnectionHandler
to decode the next frame from the input buffer.final Http2LocalFlowController
Provides the local flow controller for managing inbound traffic.Get theHttp2FrameListener
which will be notified when frames are decoded.void
frameListener
(Http2FrameListener listener) Set theHttp2FrameListener
which will be notified when frames are decoded.void
lifecycleManager
(Http2LifecycleManager lifecycleManager) Sets the lifecycle manager.Gets the local settings for this endpoint of the HTTP/2 connection.(package private) void
onGoAwayRead0
(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData) (package private) void
onUnknownFrame0
(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload) boolean
Indicates whether or not the first initialSETTINGS
frame was received from the remote endpoint.private int
unconsumedBytes
(Http2Stream stream) private void
verifyContentLength
(Http2Stream stream, int data, boolean isEnd)
-
Field Details
-
logger
-
internalFrameListener
-
connection
-
lifecycleManager
-
encoder
-
frameReader
-
listener
-
requestVerifier
-
settingsReceivedConsumer
-
autoAckPing
private final boolean autoAckPing -
contentLengthKey
-
validateHeaders
private final boolean validateHeaders
-
-
Constructor Details
-
DefaultHttp2ConnectionDecoder
public DefaultHttp2ConnectionDecoder(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader) -
DefaultHttp2ConnectionDecoder
public DefaultHttp2ConnectionDecoder(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier) -
DefaultHttp2ConnectionDecoder
public DefaultHttp2ConnectionDecoder(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier, boolean autoAckSettings) Create a new instance.- Parameters:
connection
- TheHttp2Connection
associated with this decoder.encoder
- TheHttp2ConnectionEncoder
associated with this decoder.frameReader
- Responsible for reading/parsing the raw frames. As opposed to this object which applies h2 semantics on top of the frames.requestVerifier
- Determines if push promised streams are valid.autoAckSettings
-false
to disable automatically applying and sending settings acknowledge frame. TheHttp2ConnectionEncoder
is expected to be an instance ofHttp2SettingsReceivedConsumer
and will apply the earliest received but not yet ACKed SETTINGS when writing the SETTINGS ACKs.true
to enable automatically applying and sending settings acknowledge frame.
-
DefaultHttp2ConnectionDecoder
@Deprecated public DefaultHttp2ConnectionDecoder(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier, boolean autoAckSettings, boolean autoAckPing) Deprecated. -
DefaultHttp2ConnectionDecoder
public DefaultHttp2ConnectionDecoder(Http2Connection connection, Http2ConnectionEncoder encoder, Http2FrameReader frameReader, Http2PromisedRequestVerifier requestVerifier, boolean autoAckSettings, boolean autoAckPing, boolean validateHeaders) Create a new instance.- Parameters:
connection
- TheHttp2Connection
associated with this decoder.encoder
- TheHttp2ConnectionEncoder
associated with this decoder.frameReader
- Responsible for reading/parsing the raw frames. As opposed to this object which applies h2 semantics on top of the frames.requestVerifier
- Determines if push promised streams are valid.autoAckSettings
-false
to disable automatically applying and sending settings acknowledge frame. TheHttp2ConnectionEncoder
is expected to be an instance ofHttp2SettingsReceivedConsumer
and will apply the earliest received but not yet ACKed SETTINGS when writing the SETTINGS ACKs.true
to enable automatically applying and sending settings acknowledge frame.autoAckPing
-false
to disable automatically sending ping acknowledge frame.true
to enable automatically sending ping ack frame.
-
-
Method Details
-
lifecycleManager
Description copied from interface:Http2ConnectionDecoder
Sets the lifecycle manager. Must be called as part of initialization before the decoder is used.- Specified by:
lifecycleManager
in interfaceHttp2ConnectionDecoder
-
connection
Description copied from interface:Http2ConnectionDecoder
Provides direct access to the underlying connection.- Specified by:
connection
in interfaceHttp2ConnectionDecoder
-
flowController
Description copied from interface:Http2ConnectionDecoder
Provides the local flow controller for managing inbound traffic.- Specified by:
flowController
in interfaceHttp2ConnectionDecoder
-
frameListener
Description copied from interface:Http2ConnectionDecoder
Set theHttp2FrameListener
which will be notified when frames are decoded.This must be set before frames are decoded.
- Specified by:
frameListener
in interfaceHttp2ConnectionDecoder
-
frameListener
Description copied from interface:Http2ConnectionDecoder
Get theHttp2FrameListener
which will be notified when frames are decoded.- Specified by:
frameListener
in interfaceHttp2ConnectionDecoder
-
prefaceReceived
public boolean prefaceReceived()Description copied from interface:Http2ConnectionDecoder
Indicates whether or not the first initialSETTINGS
frame was received from the remote endpoint.- Specified by:
prefaceReceived
in interfaceHttp2ConnectionDecoder
-
decodeFrame
public void decodeFrame(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Http2Exception Description copied from interface:Http2ConnectionDecoder
Called by theHttp2ConnectionHandler
to decode the next frame from the input buffer.- Specified by:
decodeFrame
in interfaceHttp2ConnectionDecoder
- Throws:
Http2Exception
-
localSettings
Description copied from interface:Http2ConnectionDecoder
Gets the local settings for this endpoint of the HTTP/2 connection.- Specified by:
localSettings
in interfaceHttp2ConnectionDecoder
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceHttp2ConnectionDecoder
-
calculateMaxHeaderListSizeGoAway
protected long calculateMaxHeaderListSizeGoAway(long maxHeaderListSize) Calculate the threshold in bytes which should trigger aGO_AWAY
if a set of headers exceeds this amount.- Parameters:
maxHeaderListSize
- SETTINGS_MAX_HEADER_LIST_SIZE for the local endpoint.- Returns:
- the threshold in bytes which should trigger a
GO_AWAY
if a set of headers exceeds this amount.
-
unconsumedBytes
-
onGoAwayRead0
void onGoAwayRead0(ChannelHandlerContext ctx, int lastStreamId, long errorCode, ByteBuf debugData) throws Http2Exception - Throws:
Http2Exception
-
onUnknownFrame0
void onUnknownFrame0(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload) throws Http2Exception - Throws:
Http2Exception
-
verifyContentLength
- Throws:
Http2Exception
-