Class TyrusHttpUpgradeHandler

java.lang.Object
org.glassfish.tyrus.servlet.TyrusHttpUpgradeHandler
All Implemented Interfaces:
jakarta.servlet.http.HttpUpgradeHandler, jakarta.servlet.ReadListener, EventListener

public class TyrusHttpUpgradeHandler extends Object implements jakarta.servlet.http.HttpUpgradeHandler, jakarta.servlet.ReadListener
HttpUpgradeHandler and ReadListener implementation.

Reads data from ServletInputStream and passes it further to the Tyrus runtime.

Author:
Jitendra Kotamraju, Pavel Bucek
  • Field Details

    • FRAME_BUFFER_SIZE

      public static final String FRAME_BUFFER_SIZE

      The size to precede OutOfMemory Exception and potentially DDoS attacks when buffering incoming WebSocket frames.

      The default value is 4194315 bytes, which correspond to 4M plus few bytes to frame headers.

      See Also:
  • Constructor Details

    • TyrusHttpUpgradeHandler

      public TyrusHttpUpgradeHandler()
  • Method Details

    • init

      public void init(jakarta.servlet.http.WebConnection wc)
      Specified by:
      init in interface jakarta.servlet.http.HttpUpgradeHandler
    • preInit

      public void preInit(WebSocketEngine.UpgradeInfo upgradeInfo, Writer writer, boolean authenticated)
      Sets the required information before init(WebConnection) is invoked.
      Parameters:
      upgradeInfo - The WebSocket UpgradeInfo.
      writer - The Tyrus SPI Writer.
      authenticated - Whether the authentication has been used.
    • onDataAvailable

      public void onDataAvailable()
      Specified by:
      onDataAvailable in interface jakarta.servlet.ReadListener
    • onAllDataRead

      public void onAllDataRead()
      Specified by:
      onAllDataRead in interface jakarta.servlet.ReadListener
    • onError

      public void onError(Throwable t)
      Specified by:
      onError in interface jakarta.servlet.ReadListener
    • destroy

      public void destroy()
      Specified by:
      destroy in interface jakarta.servlet.http.HttpUpgradeHandler
    • sessionDestroyed

      public void sessionDestroyed()
      Called when related HttpSession is destroyed or invalidated.

      Implementation is required to call onClose() on server-side with corresponding close code (1008, see WebSocket spec 7.2) - only when there is an authorized user for this session.

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setIncomingBufferSize

      public void setIncomingBufferSize(int incomingBufferSize)
      Override the default FRAME_BUFFER_SIZE.
      Parameters:
      incomingBufferSize - The new incoming frame buffer size value.