Class SpdyHandlerFilter

java.lang.Object
org.glassfish.grizzly.filterchain.BaseFilter
org.glassfish.grizzly.http.HttpBaseFilter
org.glassfish.grizzly.spdy.SpdyHandlerFilter
All Implemented Interfaces:
org.glassfish.grizzly.filterchain.Filter

public class SpdyHandlerFilter extends org.glassfish.grizzly.http.HttpBaseFilter
The 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

    Constructors
    Constructor
    Description
    Constructs SpdyHandlerFilter.
    SpdyHandlerFilter(SpdyMode spdyMode, ExecutorService threadPool, SpdyVersion... supportedSpdyVersions)
    Constructs SpdyHandlerFilter.
    SpdyHandlerFilter(SpdyMode spdyMode, SpdyVersion... supportedSpdyVersions)
    Constructs SpdyHandlerFilter.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected SpdySession
    createSpdySession(SpdyVersion spdyVersion, org.glassfish.grizzly.Connection connection, boolean isServer)
    Creates SpdySession with preconfigured initial-windows-size and max-concurrent-
    protected org.glassfish.grizzly.npn.ClientSideNegotiator
    Returns the client NPN negotiator to be used if this filter is used in the client-side filter chain.
    int
    Returns the default initial stream window size (in bytes) for new SPDY sessions.
    int
    Returns the default maximum number of concurrent streams allowed for one session.
    org.glassfish.grizzly.filterchain.NextAction
    handleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
     
    org.glassfish.grizzly.filterchain.NextAction
    handleEvent(org.glassfish.grizzly.filterchain.FilterChainContext ctx, org.glassfish.grizzly.filterchain.FilterChainEvent event)
     
    org.glassfish.grizzly.filterchain.NextAction
    handleRead(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
     
    org.glassfish.grizzly.filterchain.NextAction
    handleWrite(org.glassfish.grizzly.filterchain.FilterChainContext ctx)
     
    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.
    protected void
    onHttpContentError(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 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.
    protected void
    onHttpHeaderError(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 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.
    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.
    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.
    protected boolean
    onHttpPacketParsed(org.glassfish.grizzly.http.HttpHeader httpHeader, org.glassfish.grizzly.filterchain.FilterChainContext ctx)
    Callback method, called when HttpPacket parsing has been completed.
    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.
    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.
    void
    setInitialWindowSize(int initialWindowSize)
    Sets the default initial stream window size (in bytes) for new SPDY sessions.
    void
    setMaxConcurrentStreams(int maxConcurrentStreams)
    Sets the default maximum number of concurrent streams allowed for one session.

    Methods inherited from class org.glassfish.grizzly.http.HttpBaseFilter

    bind

    Methods inherited from class org.glassfish.grizzly.filterchain.BaseFilter

    createContext, exceptionOccurred, handleAccept, handleClose, onAdded, onFilterChainChanged, onRemoved, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • SpdyHandlerFilter

      public SpdyHandlerFilter(SpdyMode spdyMode)
      Constructs SpdyHandlerFilter.
      Parameters:
      spdyMode - the SpdyMode.
    • SpdyHandlerFilter

      public SpdyHandlerFilter(SpdyMode spdyMode, SpdyVersion... supportedSpdyVersions)
      Constructs SpdyHandlerFilter.
      Parameters:
      spdyMode - the SpdyMode.
      supportedSpdyVersions - SPDY versions this filter has to support
    • SpdyHandlerFilter

      public SpdyHandlerFilter(SpdyMode spdyMode, ExecutorService threadPool, SpdyVersion... supportedSpdyVersions)
      Constructs SpdyHandlerFilter.
      Parameters:
      spdyMode - the SpdyMode.
      threadPool - the ExecutorService to be used to process SynStreamFrame and SynReplyFrame frames, 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:
      handleRead in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleRead in class org.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 when HttpPacket parsing has been completed.
      Parameters:
      httpHeader - HttpHeader, which represents parsed HTTP packet header
      ctx - processing context.
      Returns:
      true if an error has occurred while processing the header portion of the HTTP request, otherwise returns false.
      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 header
      buffer - Buffer the header was parsed from
      ctx - processing context.
      Returns:
      true if an error has occurred while processing the header portion of the HTTP request, otherwise returns false.
      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 header
      ctx - 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 header
      ctx - 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 header
      ctx - 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 header
      ctx - 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 content
      ctx - 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 header
      ctx - 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 header
      ctx - the FilterChainContext processing this request
      t - 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 header
      ctx - the FilterChainContext processing this request
      t - 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:
      handleWrite in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleWrite in class org.glassfish.grizzly.filterchain.BaseFilter
      Throws:
      IOException
    • handleConnect

      public org.glassfish.grizzly.filterchain.NextAction handleConnect(org.glassfish.grizzly.filterchain.FilterChainContext ctx) throws IOException
      Specified by:
      handleConnect in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleConnect in class org.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:
      handleEvent in interface org.glassfish.grizzly.filterchain.Filter
      Overrides:
      handleEvent in class org.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)
      Creates SpdySession with preconfigured initial-windows-size and max-concurrent-
      Parameters:
      spdyVersion -
      connection -
      isServer -
      Returns: