Class SpdyHandlerFilter
- All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter
Filter serves as a bridge
between SPDY and HTTP layers by converting SpdyFrames into
HttpPackets and passing them up/down by the FilterChain.
Additionally this Filter has
logic responsible for checking SPDY protocol semantics and fire correspondent
events and messages in case when SPDY semantics is broken.- Author:
- Grizzly team
-
Constructor Summary
ConstructorsConstructorDescriptionSpdyHandlerFilter(SpdyMode spdyMode) Constructs SpdyHandlerFilter.SpdyHandlerFilter(SpdyMode spdyMode, ExecutorService threadPool, SpdyVersion... supportedSpdyVersions) Constructs SpdyHandlerFilter.SpdyHandlerFilter(SpdyMode spdyMode, SpdyVersion... supportedSpdyVersions) Constructs SpdyHandlerFilter. -
Method Summary
Modifier and TypeMethodDescriptionprotected SpdySessioncreateSpdySession(SpdyVersion spdyVersion, org.glassfish.grizzly.Connection connection, boolean isServer) CreatesSpdySessionwith preconfigured initial-windows-size and max-concurrent-protected org.glassfish.grizzly.npn.ClientSideNegotiatorReturns the client NPN negotiator to be used if this filter is used in the client-side filter chain.intReturns the default initial stream window size (in bytes) for new SPDY sessions.intReturns the default maximum number of concurrent streams allowed for one session.org.glassfish.grizzly.filterchain.NextActionhandleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) org.glassfish.grizzly.filterchain.NextActionhandleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event) org.glassfish.grizzly.filterchain.NextActionhandleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) org.glassfish.grizzly.filterchain.NextActionhandleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx) protected voidonHttpContentEncoded(org.glassfish.grizzly.http.HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.protected voidonHttpContentError(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) Callback which is invoked when parsing an HTTP message payload fails.protected voidonHttpContentParsed(org.glassfish.grizzly.http.HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked as request/response body content has been processed by thisFilter.protected voidonHttpHeaderError(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) Callback which is invoked when parsing an HTTP message header fails.protected booleanonHttpHeaderParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Callback invoked when the HTTP message header parsing is complete.protected voidonHttpHeadersEncoded(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.protected voidonHttpHeadersParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when all headers of the packet have been parsed.protected booleanonHttpPacketParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Callback method, called whenHttpPacketparsing has been completed.protected voidonInitialLineEncoded(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when the intial response line has been encoded in preparation to being transmitted to the user-agent.protected voidonInitialLineParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when either the request line or status line has been parsed.voidsetInitialWindowSize(int initialWindowSize) Sets the default initial stream window size (in bytes) for new SPDY sessions.voidsetMaxConcurrentStreams(int maxConcurrentStreams) Sets the default maximum number of concurrent streams allowed for one session.Methods inherited from class org.glassfish.grizzly.http.HttpBaseFilter
bindMethods inherited from class org.glassfish.grizzly.filterchain.BaseFilter
createContext, exceptionOccurred, handleAccept, handleClose, onAdded, onFilterChainChanged, onRemoved, toString
-
Constructor Details
-
SpdyHandlerFilter
Constructs SpdyHandlerFilter.- Parameters:
spdyMode- theSpdyMode.
-
SpdyHandlerFilter
Constructs SpdyHandlerFilter.- Parameters:
spdyMode- theSpdyMode.supportedSpdyVersions- SPDY versions this filter has to support
-
SpdyHandlerFilter
public SpdyHandlerFilter(SpdyMode spdyMode, ExecutorService threadPool, SpdyVersion... supportedSpdyVersions) Constructs SpdyHandlerFilter.- Parameters:
spdyMode- theSpdyMode.threadPool- theExecutorServiceto be used to processSynStreamFrameandSynReplyFrameframes, if null mentioned frames will be processed in the same thread they were parsed.supportedSpdyVersions- SPDY versions this filter has to support
-
-
Method Details
-
setMaxConcurrentStreams
public void setMaxConcurrentStreams(int maxConcurrentStreams) Sets the default maximum number of concurrent streams allowed for one session. Negative value means "unlimited". -
getMaxConcurrentStreams
public int getMaxConcurrentStreams()Returns the default maximum number of concurrent streams allowed for one session. Negative value means "unlimited". -
setInitialWindowSize
public void setInitialWindowSize(int initialWindowSize) Sets the default initial stream window size (in bytes) for new SPDY sessions. -
getInitialWindowSize
public int getInitialWindowSize()Returns the default initial stream window size (in bytes) for new SPDY sessions. -
handleRead
public org.glassfish.grizzly.filterchain.NextAction handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException - Specified by:
handleReadin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleReadin classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
onHttpPacketParsed
protected boolean onHttpPacketParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Callback method, called whenHttpPacketparsing has been completed.- Parameters:
httpHeader-HttpHeader, which represents parsed HTTP packet headerctx- processing context.- Returns:
trueif an error has occurred while processing the header portion of the HTTP request, otherwise returnsfalse.- Since:
- 2.3.3
-
onHttpHeaderParsed
protected boolean onHttpHeaderParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.Buffer buffer, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Callback invoked when the HTTP message header parsing is complete.- Parameters:
httpHeader-HttpHeader, which represents parsed HTTP packet headerbuffer-Bufferthe header was parsed fromctx- processing context.- Returns:
trueif an error has occurred while processing the header portion of the HTTP request, otherwise returnsfalse.- Since:
- 2.3.3
-
onInitialLineParsed
protected void onInitialLineParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when either the request line or status line has been parsed.
- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.- Since:
- 2.3.3
-
onInitialLineEncoded
protected void onInitialLineEncoded(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when the intial response line has been encoded in preparation to being transmitted to the user-agent.
- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.- Since:
- 2.3.3
-
onHttpHeadersParsed
protected void onHttpHeadersParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when all headers of the packet have been parsed. Depending on the transfer encoding being used by the current request, this method may be invoked multiple times.
- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.- Since:
- 2.3.3
-
onHttpHeadersEncoded
protected void onHttpHeadersEncoded(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when HTTP headers have been encoded in preparation to being transmitted to the user-agent.
- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- processing context.- Since:
- 2.3.3
-
onHttpContentParsed
protected void onHttpContentParsed(org.glassfish.grizzly.http.HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked as request/response body content has been processed by this
Filter.- Parameters:
content- request/response body contentctx- processing context.- Since:
- 2.3.3
-
onHttpContentEncoded
protected void onHttpContentEncoded(org.glassfish.grizzly.http.HttpContent content, org.glassfish.grizzly.filterchain.FilterChainContext ctx) Invoked when a HTTP body chunk has been encoded in preparation to being transmitted to the user-agent.
- Parameters:
content-HttpContent, which represents HTTP packet headerctx- processing context.- Since:
- 2.3.3
-
onHttpHeaderError
protected void onHttpHeaderError(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException Callback which is invoked when parsing an HTTP message header fails. The processing logic has to take care about error handling and following connection closing.
- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- theFilterChainContextprocessing this requestt- the cause of the error- Throws:
IOException- Since:
- 2.3.3
-
onHttpContentError
protected void onHttpContentError(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx, Throwable t) throws IOException Callback which is invoked when parsing an HTTP message payload fails. The processing logic has to take care about error handling and following connection closing.
- Parameters:
httpHeader-HttpHeader, which represents HTTP packet headerctx- theFilterChainContextprocessing this requestt- the cause of the error- Throws:
IOException- Since:
- 2.3.3
-
handleWrite
public org.glassfish.grizzly.filterchain.NextAction handleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException - Specified by:
handleWritein interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleWritein classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
handleConnect
public org.glassfish.grizzly.filterchain.NextAction handleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException - Specified by:
handleConnectin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleConnectin classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
handleEvent
public org.glassfish.grizzly.filterchain.NextAction handleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event) throws IOException - Specified by:
handleEventin interfaceorg.glassfish.grizzly.filterchain.Filter- Overrides:
handleEventin classorg.glassfish.grizzly.filterchain.BaseFilter- Throws:
IOException
-
getClientNpnNegotioator
protected org.glassfish.grizzly.npn.ClientSideNegotiator getClientNpnNegotioator()Returns the client NPN negotiator to be used if this filter is used in the client-side filter chain. -
createSpdySession
protected SpdySession createSpdySession(SpdyVersion spdyVersion, org.glassfish.grizzly.Connection connection, boolean isServer) CreatesSpdySessionwith preconfigured initial-windows-size and max-concurrent-- Parameters:
spdyVersion-connection-isServer-- Returns:
-