Top Description Fields Constructors Methods
org.glassfish.grizzly.http2

public abstract Class Http2BaseFilter

extends HttpBaseFilter
Class Inheritance
Known Direct Subclasses
org.glassfish.grizzly.http2.Http2ClientFilter, org.glassfish.grizzly.http2.Http2ServerFilter
Imports
java.io.IOException, java.util.List, java.util.concurrent.ExecutorService, java.util.logging.Level, .Logger, org.glassfish.grizzly.Buffer, .Connection, .Grizzly, org.glassfish.grizzly.filterchain.FilterChain, .FilterChainContext, .FilterChainContext.TransportContext, .FilterChainEvent, .NextAction, .TransportFilter, org.glassfish.grizzly.http.FixedLengthTransferEncoding, .HttpBaseFilter, .HttpContent, .HttpContext, .HttpHeader, .HttpPacket, .HttpRequestPacket, .HttpResponsePacket, .Method, .ProcessingState, .Protocol, .TransferEncoding, org.glassfish.grizzly.http.util.DataChunk, .Header, .HttpStatus, .MimeHeaders, org.glassfish.grizzly.http2.frames.ContinuationFrame, .DataFrame, .ErrorCode, .GoAwayFrame, .HeaderBlockFragment, .HeaderBlockHead, .HeadersFrame, .Http2Frame, .PingFrame, .PriorityFrame, .PushPromiseFrame, .RstStreamFrame, .SettingsFrame, .WindowUpdateFrame, org.glassfish.grizzly.threadpool.GrizzlyExecutorService, .ThreadPoolConfig, .Threads, org.glassfish.grizzly.utils.Charsets

The org.glassfish.grizzly.filterchain.Filter serves as a bridge between HTTP2 frames and upper-level HTTP layers by converting Http2Frames into HttpPackets and passing them up/down by the FilterChain. Additionally this org.glassfish.grizzly.filterchain.Filter has logic responsible for checking HTTP2 protocol semantics and fire correspondent events and messages in case when HTTP2 semantics is broken.
Author
Grizzly team

Field Summary

Modifier and TypeField and Description
private final Http2Configuration
protected static final TransferEncoding
pack-priv final Http2FrameCodec
pack-priv static final String
HTTP2_CLEAR

Token for clear-text HTTP/2.0.

pack-priv static final String
HTTP2_PUSH_ENABLED

Attribute name for associating push status.

private int
private static final Logger
pack-priv static final byte[]
protected final ExecutorService

Constructor Summary

AccessConstructor and Description
public
Http2BaseFilter(final Http2Configuration configuration)

Constructs Http2HandlerFilter.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
applySettings(final Http2Session http2Session, final SettingsFrame settingsFrame)

pack-priv boolean
protected boolean
protected boolean
protected Http2Session

Returns:

Http2Session
createHttp2Session
(final Connection<L>
the TCP Connection
connection
,
final boolean
flag indicating whether this connection is server side or not.
isServer
)

Creates Http2Session with pre-configured initial-windows-size and max-concurrent-streams

public Http2Configuration
getConfiguration()

Returns: the Http2Configuration backing this filter.

protected SettingsFrame
public int
getLocalMaxFramePayloadSize()

Returns: the maximum allowed HTTP2 frame payload size

public NextAction
public NextAction
handleWrite(final FilterChainContext ctx)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Execute a unit of processing work to be performed, when some data should be written on channel.

protected static boolean
ignoreFrameForStreamId(final Http2Session session, final int streamId)

protected boolean
protected final Http2Session

Returns:

Http2Session associated with the Connection and prepare it for use
obtainHttp2Session
(final FilterChainContext context, final boolean
true if the FilterChainContext represents upstream FilterChain execution, or false otherwise
isUpStream
)

Obtain Http2Session associated with the Connection and prepare it for use.

pack-priv final Http2Session

Returns:

Http2Session associated with the Connection and prepare it for use
obtainHttp2Session
(final Http2State
Http2State associated with the Connection
http2State
,
final FilterChainContext context, final boolean
true if the FilterChainContext represents upstream FilterChain execution, or false otherwise
isUpStream
)

Obtain Http2Session associated with the Connection and prepare it for use.

protected void
protected void
protected void
protected void
onHttpHeaderError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t)

protected boolean
protected void
onHttpHeadersEncoded(final HttpHeader httpHeader, final FilterChainContext ctx)

protected void
onHttpHeadersParsed(final HttpHeader httpHeader, final FilterChainContext ctx)

protected boolean
protected void
onInitialLineEncoded(final HttpHeader httpHeader, final FilterChainContext ctx)

protected void
onInitialLineParsed(final HttpHeader httpHeader, final FilterChainContext ctx)

protected void
onPrefaceReceived(final Http2Session http2Session)

pack-priv void
prepareIncomingRequest(final Http2Stream stream, final Http2Request request)

protected void
protected abstract void
processCompleteHeader(final Http2Session
the Http2Session associated with this header.
http2Session
,
final FilterChainContext
the current FilterChainContext
context
,
final HeaderBlockHead
the first HeaderBlockHead from the first HeadersFrame received.
firstHeaderFrame
)

The method is called once complete HTTP header block arrives on Http2Session.

private static void
processDataFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame)

protected boolean
processFrames(final FilterChainContext ctx, final Http2Session http2Session, final List<Http2Frame> framesList)

private void
processGoAwayFrame(final Http2Session http2Session, final Http2Frame frame)

private void
processHeadersFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame)

private void
processInFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame)

protected abstract void
processOutgoingHttpHeader(final FilterChainContext ctx, final Http2Session http2Session, final HttpHeader httpHeader, final HttpPacket entireHttpPacket)

private void
processPingFrame(final Http2Session http2Session, final Http2Frame frame)

private void
private void
processRstStreamFrame(final Http2Session http2Session, final Http2Frame frame)

private void
processSettingsFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame)

private void
processWindowUpdateFrame(final Http2Session http2Session, final Http2Frame frame)

pack-priv void
sendRstStream(final FilterChainContext ctx, final Http2Session http2Session, final int streamId, final ErrorCode errorCode)

private void
sendSettingsAck(final Http2Session http2Session, final FilterChainContext context)

pack-priv void
sendUpstream(final Http2Session http2Session, final Http2Stream stream, final HttpContent content)

public void
setLocalMaxFramePayloadSize(final int
the maximum allowed HTTP2 frame size
localMaxFramePayloadSize
)

Sets the maximum allowed HTTP2 frame size.

Inherited from org.glassfish.grizzly.http.HttpBaseFilter:
bind

Field Detail

configurationback to summary
private final Http2Configuration configuration
FIXED_LENGTH_ENCODINGback to summary
protected static final TransferEncoding FIXED_LENGTH_ENCODING
frameCodecback to summary
pack-priv final Http2FrameCodec frameCodec
HTTP2_CLEARback to summary
pack-priv static final String HTTP2_CLEAR

Token for clear-text HTTP/2.0.

HTTP2_PUSH_ENABLEDback to summary
pack-priv static final String HTTP2_PUSH_ENABLED

Attribute name for associating push status.

localMaxFramePayloadSizeback to summary
private int localMaxFramePayloadSize
LOGGERback to summary
private static final Logger LOGGER
PRI_PAYLOADback to summary
pack-priv static final byte[] PRI_PAYLOAD
threadPoolback to summary
protected final ExecutorService threadPool

Constructor Detail

Http2BaseFilterback to summary
public Http2BaseFilter(final Http2Configuration configuration)

Constructs Http2HandlerFilter.

Method Detail

applySettingsback to summary
pack-priv void applySettings(final Http2Session http2Session, final SettingsFrame settingsFrame) throws Http2SessionException, Http2StreamException
checkIfHttp2StreamChainback to summary
pack-priv boolean checkIfHttp2StreamChain(final FilterChainContext ctx) throws IOException
checkRequestHeadersOnUpgradeback to summary
protected boolean checkRequestHeadersOnUpgrade(final HttpRequestPacket httpRequest)
checkResponseHeadersOnUpgradeback to summary
protected boolean checkResponseHeadersOnUpgrade(final HttpResponsePacket httpResponse)
createHttp2Sessionback to summary
protected Http2Session createHttp2Session(final Connection<L> connection, final boolean isServer)

Creates Http2Session with pre-configured initial-windows-size and max-concurrent-streams

Parameters
connection:Connection<L>

the TCP Connection

isServer:boolean

flag indicating whether this connection is server side or not.

Returns:Http2Session

Http2Session

getConfigurationback to summary
public Http2Configuration getConfiguration()
Returns:Http2Configuration

the Http2Configuration backing this filter.

getHttp2UpgradeSettingsback to summary
protected SettingsFrame getHttp2UpgradeSettings(final HttpRequestPacket httpRequest)
getLocalMaxFramePayloadSizeback to summary
public int getLocalMaxFramePayloadSize()
Returns:int

the maximum allowed HTTP2 frame payload size

handleEventback to summary
public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleEvent.

Implements org.glassfish.grizzly.filterchain.Filter.handleEvent.

Doc from org.glassfish.grizzly.filterchain.BaseFilter.handleEvent.

Handle custom event associated with the Connection. This Filter may either complete the required processing and return StopAction, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning InvokeAction.

Annotations
@Override
@SuppressWarnings:unchecked
handleWriteback to summary
public NextAction handleWrite(final FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Doc from org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Execute a unit of processing work to be performed, when some data should be written on channel. This Filter may either complete the required processing and return false, or delegate remaining processing to the next Filter in a FilterChain containing this Filter by returning true.

Annotations
@Override
@SuppressWarnings:unchecked
ignoreFrameForStreamIdback to summary
protected static boolean ignoreFrameForStreamId(final Http2Session session, final int streamId)
isHttp2UpgradingVersionback to summary
protected boolean isHttp2UpgradingVersion(final HttpHeader httpHeader)
obtainHttp2Sessionback to summary
protected final Http2Session obtainHttp2Session(final FilterChainContext context, final boolean isUpStream)

Obtain Http2Session associated with the Connection and prepare it for use.

Parameters
context:FilterChainContext

FilterChainContext

isUpStream:boolean

true if the FilterChainContext represents upstream FilterChain execution, or false otherwise

Returns:Http2Session

Http2Session associated with the Connection and prepare it for use

Annotations
@SuppressWarnings:SameParameterValue
obtainHttp2Sessionback to summary
pack-priv final Http2Session obtainHttp2Session(final Http2State http2State, final FilterChainContext context, final boolean isUpStream)

Obtain Http2Session associated with the Connection and prepare it for use.

Parameters
http2State:Http2State

Http2State associated with the Connection

context:FilterChainContext

FilterChainContext

isUpStream:boolean

true if the FilterChainContext represents upstream FilterChain execution, or false otherwise

Returns:Http2Session

Http2Session associated with the Connection and prepare it for use

onHttpContentEncodedback to summary
protected void onHttpContentEncoded(final HttpContent content, final FilterChainContext ctx)
Annotations
@SuppressWarnings:unused
onHttpContentErrorback to summary
protected void onHttpContentError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) throws IOException
Annotations
@SuppressWarnings:unused
onHttpContentParsedback to summary
protected void onHttpContentParsed(final HttpContent content, final FilterChainContext ctx)
Annotations
@SuppressWarnings:unused
onHttpHeaderErrorback to summary
protected void onHttpHeaderError(final HttpHeader httpHeader, final FilterChainContext ctx, final Throwable t) throws IOException
Annotations
@SuppressWarnings:unused
onHttpHeaderParsedback to summary
protected boolean onHttpHeaderParsed(HttpHeader httpHeader, Buffer buffer, FilterChainContext ctx)
Annotations
@SuppressWarnings:UnusedReturnValue, unused
onHttpHeadersEncodedback to summary
protected void onHttpHeadersEncoded(final HttpHeader httpHeader, final FilterChainContext ctx)
Annotations
@SuppressWarnings:unused
onHttpHeadersParsedback to summary
protected void onHttpHeadersParsed(final HttpHeader httpHeader, final FilterChainContext ctx)
Annotations
@SuppressWarnings:unused
onHttpPacketParsedback to summary
protected boolean onHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx)
Annotations
@SuppressWarnings:UnusedReturnValue, unused
onInitialLineEncodedback to summary
protected void onInitialLineEncoded(final HttpHeader httpHeader, final FilterChainContext ctx)
Annotations
@SuppressWarnings:unused
onInitialLineParsedback to summary
protected void onInitialLineParsed(final HttpHeader httpHeader, final FilterChainContext ctx)
Annotations
@SuppressWarnings:unused
onPrefaceReceivedback to summary
protected void onPrefaceReceived(final Http2Session http2Session)
prepareIncomingRequestback to summary
pack-priv void prepareIncomingRequest(final Http2Stream stream, final Http2Request request)
prepareOutgoingRequestback to summary
protected void prepareOutgoingRequest(final HttpRequestPacket request)
processCompleteHeaderback to summary
protected abstract void processCompleteHeader(final Http2Session http2Session, final FilterChainContext context, final HeaderBlockHead firstHeaderFrame) throws IOException

The method is called once complete HTTP header block arrives on Http2Session.

Parameters
http2Session:Http2Session

the Http2Session associated with this header.

context:FilterChainContext

the current FilterChainContext

firstHeaderFrame:HeaderBlockHead

the first HeaderBlockHead from the first HeadersFrame received.

Exceptions
IOException:
if an error occurs when dealing with the event.
processDataFrameback to summary
private static void processDataFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame) throws IOException
processFramesback to summary
protected boolean processFrames(final FilterChainContext ctx, final Http2Session http2Session, final List<Http2Frame> framesList)
processGoAwayFrameback to summary
private void processGoAwayFrame(final Http2Session http2Session, final Http2Frame frame) throws Http2SessionException
processHeadersFrameback to summary
private void processHeadersFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame) throws IOException
processInFrameback to summary
private void processInFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame) throws Http2StreamException, Http2SessionException, IOException
Annotations
@SuppressWarnings:DuplicateThrows
processOutgoingHttpHeaderback to summary
protected abstract void processOutgoingHttpHeader(final FilterChainContext ctx, final Http2Session http2Session, final HttpHeader httpHeader, final HttpPacket entireHttpPacket) throws IOException
processPingFrameback to summary
private void processPingFrame(final Http2Session http2Session, final Http2Frame frame) throws Http2SessionException
processPriorityFrameback to summary
private void processPriorityFrame(final Http2Frame frame) throws Http2SessionException, Http2StreamException
processRstStreamFrameback to summary
private void processRstStreamFrame(final Http2Session http2Session, final Http2Frame frame) throws Http2SessionException
processSettingsFrameback to summary
private void processSettingsFrame(final Http2Session http2Session, final FilterChainContext context, final Http2Frame frame) throws Http2SessionException, Http2StreamException
processWindowUpdateFrameback to summary
private void processWindowUpdateFrame(final Http2Session http2Session, final Http2Frame frame) throws Http2StreamException, Http2SessionException
sendRstStreamback to summary
pack-priv void sendRstStream(final FilterChainContext ctx, final Http2Session http2Session, final int streamId, final ErrorCode errorCode)
sendSettingsAckback to summary
private void sendSettingsAck(final Http2Session http2Session, final FilterChainContext context)
sendUpstreamback to summary
pack-priv void sendUpstream(final Http2Session http2Session, final Http2Stream stream, final HttpContent content)
setLocalMaxFramePayloadSizeback to summary
public void setLocalMaxFramePayloadSize(final int localMaxFramePayloadSize)

Sets the maximum allowed HTTP2 frame size.

Parameters
localMaxFramePayloadSize:int

the maximum allowed HTTP2 frame size