Class WebSocketUpgradeFilter

java.lang.Object
org.eclipse.jetty.websocket.servlet.WebSocketUpgradeFilter
All Implemented Interfaces:
javax.servlet.Filter, Dumpable

@ManagedObject("WebSocket Upgrade Filter") public class WebSocketUpgradeFilter extends Object implements javax.servlet.Filter, Dumpable
Inline Servlet Filter to capture WebSocket upgrade requests.

The configuration applied to this filter via init params will be used as the the default configuration of any websocket upgraded by this filter, prior to the configuration of the websocket applied by the WebSocketMappings.

Configuration / Init-Parameters:

idleTimeout
set the time in ms that a websocket may be idle before closing
maxTextMessageSize
set the size in UTF-8 bytes that a websocket may be accept as a Text Message before closing
maxBinaryMessageSize
set the size in bytes that a websocket may be accept as a Binary Message before closing
inputBufferSize
set the size in bytes of the buffer used to read raw bytes from the network layer
outputBufferSize
set the size in bytes of the buffer used to write bytes to the network layer
maxFrameSize
The maximum frame size sent or received.
autoFragment
If true, frames are automatically fragmented to respect the maximum frame size.
  • Constructor Details

    • WebSocketUpgradeFilter

      public WebSocketUpgradeFilter()
  • Method Details

    • getFilter

      public static FilterHolder getFilter(javax.servlet.ServletContext servletContext)
      Return the default WebSocketUpgradeFilter if present on the ServletContext.
      Parameters:
      servletContext - the ServletContext to use.
      Returns:
      the configured default WebSocketUpgradeFilter instance.
    • ensureFilter

      public static FilterHolder ensureFilter(javax.servlet.ServletContext servletContext)
      Ensure a WebSocketUpgradeFilter is available on the provided ServletContext, a new filter will added if one does not already exist.

      The default WebSocketUpgradeFilter is also available via the ServletContext attribute named org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter

      Parameters:
      servletContext - the ServletContext to use.
      Returns:
      the configured default WebSocketUpgradeFilter instance.
    • doFilter

      public void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain) throws IOException, javax.servlet.ServletException
      Specified by:
      doFilter in interface javax.servlet.Filter
      Throws:
      IOException
      javax.servlet.ServletException
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Description copied from interface: Dumpable
      Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
      Specified by:
      dump in interface Dumpable
      Parameters:
      out - The appendable to dump to
      indent - The indent to apply after any new lines.
      Throws:
      IOException - if unable to write to Appendable
    • init

      public void init(javax.servlet.FilterConfig config) throws javax.servlet.ServletException
      Specified by:
      init in interface javax.servlet.Filter
      Throws:
      javax.servlet.ServletException
    • destroy

      public void destroy()
      Specified by:
      destroy in interface javax.servlet.Filter