Package org.glassfish.grizzly.http2
Class Http2BaseFilter
java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.http.HttpBaseFilter
org.glassfish.grizzly.http2.Http2BaseFilter
- All Implemented Interfaces:
Filter
- Direct Known Subclasses:
Http2ClientFilter,Http2ServerFilter
The
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 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
FieldsModifier and TypeFieldDescriptionprotected static final TransferEncodingprotected final ExecutorService -
Constructor Summary
ConstructorsConstructorDescriptionHttp2BaseFilter(Http2Configuration configuration) Constructs Http2HandlerFilter. -
Method Summary
Modifier and TypeMethodDescriptionprotected booleancheckRequestHeadersOnUpgrade(HttpRequestPacket httpRequest) protected booleancheckResponseHeadersOnUpgrade(HttpResponsePacket httpResponse) protected Http2SessioncreateHttp2Session(Connection connection, boolean isServer) CreatesHttp2Sessionwith pre-configured initial-windows-size and max-concurrent-streamsprotected SettingsFramegetHttp2UpgradeSettings(HttpRequestPacket httpRequest) inthandleEvent(FilterChainContext ctx, FilterChainEvent event) Handle custom event associated with theConnection.Execute a unit of processing work to be performed, when some data should be written on channel.protected static booleanignoreFrameForStreamId(Http2Session session, int streamId) protected booleanisHttp2UpgradingVersion(HttpHeader httpHeader) protected final Http2SessionobtainHttp2Session(FilterChainContext context, boolean isUpStream) ObtainHttp2Sessionassociated with theConnectionand prepare it for use.protected voidonHttpContentEncoded(HttpContent content, FilterChainContext ctx) protected voidonHttpContentError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) protected voidonHttpContentParsed(HttpContent content, FilterChainContext ctx) protected voidonHttpHeaderError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) protected booleanonHttpHeaderParsed(HttpHeader httpHeader, Buffer buffer, FilterChainContext ctx) protected voidonHttpHeadersEncoded(HttpHeader httpHeader, FilterChainContext ctx) protected voidonHttpHeadersParsed(HttpHeader httpHeader, FilterChainContext ctx) protected booleanonHttpPacketParsed(HttpHeader httpHeader, FilterChainContext ctx) protected voidonInitialLineEncoded(HttpHeader httpHeader, FilterChainContext ctx) protected voidonInitialLineParsed(HttpHeader httpHeader, FilterChainContext ctx) protected voidonPrefaceReceived(Http2Session http2Session) protected voidprepareOutgoingRequest(HttpRequestPacket request) protected abstract voidprocessCompleteHeader(Http2Session http2Session, FilterChainContext context, HeaderBlockHead firstHeaderFrame) The method is called once complete HTTP header block arrives onHttp2Session.protected booleanprocessFrames(FilterChainContext ctx, Http2Session http2Session, List<Http2Frame> framesList) protected abstract voidprocessOutgoingHttpHeader(FilterChainContext ctx, Http2Session http2Session, HttpHeader httpHeader, HttpPacket entireHttpPacket) voidsetLocalMaxFramePayloadSize(int localMaxFramePayloadSize) Sets the maximum allowed HTTP2 frame size.Methods inherited from class org.glassfish.grizzly.http.HttpBaseFilter
bindMethods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleAccept, handleClose, handleConnect, handleRead, onAdded, onFilterChainChanged, onRemoved, toString
-
Field Details
-
FIXED_LENGTH_ENCODING
-
threadPool
-
-
Constructor Details
-
Http2BaseFilter
Constructs Http2HandlerFilter.
-
-
Method Details
-
getLocalMaxFramePayloadSize
public int getLocalMaxFramePayloadSize()- Returns:
- the maximum allowed HTTP2 frame payload size
-
setLocalMaxFramePayloadSize
public void setLocalMaxFramePayloadSize(int localMaxFramePayloadSize) Sets the maximum allowed HTTP2 frame size.- Parameters:
localMaxFramePayloadSize- the maximum allowed HTTP2 frame size
-
getConfiguration
- Returns:
- the
Http2Configurationbacking this filter.
-
processFrames
protected boolean processFrames(FilterChainContext ctx, Http2Session http2Session, List<Http2Frame> framesList) -
checkRequestHeadersOnUpgrade
-
checkResponseHeadersOnUpgrade
-
getHttp2UpgradeSettings
-
isHttp2UpgradingVersion
-
onHttpPacketParsed
-
onHttpHeaderParsed
-
onInitialLineParsed
-
onInitialLineEncoded
-
onHttpHeadersParsed
-
onHttpHeadersEncoded
-
onHttpContentParsed
-
onHttpContentEncoded
-
onHttpHeaderError
protected void onHttpHeaderError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) throws IOException - Throws:
IOException
-
onHttpContentError
protected void onHttpContentError(HttpHeader httpHeader, FilterChainContext ctx, Throwable t) throws IOException - Throws:
IOException
-
processCompleteHeader
protected abstract void processCompleteHeader(Http2Session http2Session, FilterChainContext context, HeaderBlockHead firstHeaderFrame) throws IOException The method is called once complete HTTP header block arrives onHttp2Session.- Parameters:
http2Session- theHttp2Sessionassociated with this header.context- the currentFilterChainContextfirstHeaderFrame- the firstHeaderBlockHeadfrom the firstHeadersFramereceived.- Throws:
IOException- if an error occurs when dealing with the event.
-
handleWrite
Description copied from class:BaseFilterExecute a unit of processing work to be performed, when some data should be written on channel. ThisFiltermay either complete the required processing and return false, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returning true.- Specified by:
handleWritein interfaceFilter- Overrides:
handleWritein classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
processOutgoingHttpHeader
protected abstract void processOutgoingHttpHeader(FilterChainContext ctx, Http2Session http2Session, HttpHeader httpHeader, HttpPacket entireHttpPacket) throws IOException - Throws:
IOException
-
prepareOutgoingRequest
-
handleEvent
Description copied from class:BaseFilterHandle custom event associated with theConnection. ThisFiltermay either complete the required processing and returnStopAction, or delegate remaining processing to the nextFilterin aFilterChaincontaining thisFilterby returningInvokeAction.- Specified by:
handleEventin interfaceFilter- Overrides:
handleEventin classBaseFilter- Parameters:
ctx-FilterChainContext- Returns:
NextActioninstruction forFilterChain, how it should continue the execution- Throws:
IOException
-
createHttp2Session
CreatesHttp2Sessionwith pre-configured initial-windows-size and max-concurrent-streams- Parameters:
connection- the TCPConnectionisServer- flag indicating whether this connection is server side or not.- Returns:
Http2Session
-
onPrefaceReceived
-
obtainHttp2Session
ObtainHttp2Sessionassociated with theConnectionand prepare it for use.- Parameters:
context-FilterChainContextisUpStream- true if theFilterChainContextrepresents upstreamFilterChainexecution, or false otherwise- Returns:
Http2Sessionassociated with theConnectionand prepare it for use
-
ignoreFrameForStreamId
-