java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.websocket.common.extensions.AbstractExtension
org.eclipse.jetty.websocket.common.extensions.compress.CompressExtension
All Implemented Interfaces:
org.eclipse.jetty.util.component.LifeCycle, Extension, IncomingFrames, OutgoingFrames
Direct Known Subclasses:
DeflateFrameExtension, PerMessageDeflateExtension

public abstract class CompressExtension extends AbstractExtension
  • Field Details

    • TAIL_BYTES

      protected static final byte[] TAIL_BYTES
    • TAIL_BYTES_BUF

      protected static final ByteBuffer TAIL_BYTES_BUF
    • LOG

      private static final org.eclipse.jetty.util.log.Logger LOG
    • TAIL_DROP_NEVER

      protected static final int TAIL_DROP_NEVER
      Never drop tail bytes 0000FFFF, from any frame type
      See Also:
    • TAIL_DROP_ALWAYS

      protected static final int TAIL_DROP_ALWAYS
      Always drop tail bytes 0000FFFF, from all frame types
      See Also:
    • TAIL_DROP_FIN_ONLY

      protected static final int TAIL_DROP_FIN_ONLY
      Only drop tail bytes 0000FFFF, from fin==true frames
      See Also:
    • RSV_USE_ALWAYS

      protected static final int RSV_USE_ALWAYS
      Always set RSV flag, on all frame types
      See Also:
    • RSV_USE_ONLY_FIRST

      protected static final int RSV_USE_ONLY_FIRST
      Only set RSV flag on first frame in multi-frame messages.

      Note: this automatically means no-continuation frames have the RSV bit set

      See Also:
    • INFLATE_BUFFER_SIZE

      protected static final int INFLATE_BUFFER_SIZE
      Inflater / Decompressed Buffer Size
      See Also:
    • INPUT_MAX_BUFFER_SIZE

      protected static final int INPUT_MAX_BUFFER_SIZE
      Deflater / Inflater: Maximum Input Buffer Size
      See Also:
    • DECOMPRESS_BUF_SIZE

      private static final int DECOMPRESS_BUF_SIZE
      Inflater : Output Buffer Size
      See Also:
    • entries

      private final Queue<CompressExtension.FrameEntry> entries
    • flusher

      private final org.eclipse.jetty.util.IteratingCallback flusher
    • deflaterPool

      private org.eclipse.jetty.util.compression.DeflaterPool deflaterPool
    • inflaterPool

      private org.eclipse.jetty.util.compression.InflaterPool inflaterPool
    • deflaterImpl

      private Deflater deflaterImpl
    • inflaterImpl

      private Inflater inflaterImpl
    • decompressCount

      protected AtomicInteger decompressCount
    • tailDrop

      private int tailDrop
    • rsvUse

      private int rsvUse
  • Constructor Details

    • CompressExtension

      protected CompressExtension()
  • Method Details

    • setInflaterPool

      public void setInflaterPool(org.eclipse.jetty.util.compression.InflaterPool inflaterPool)
    • setDeflaterPool

      public void setDeflaterPool(org.eclipse.jetty.util.compression.DeflaterPool deflaterPool)
    • getDeflater

      public Deflater getDeflater()
    • getInflater

      public Inflater getInflater()
    • isRsv1User

      public boolean isRsv1User()
      Indicates use of RSV1 flag for indicating deflation is in use.
      Specified by:
      isRsv1User in interface Extension
      Overrides:
      isRsv1User in class AbstractExtension
      Returns:
      true if extension uses RSV1 for its own purposes.
    • getTailDropMode

      abstract int getTailDropMode()
      Return the mode of operation for dropping (or keeping) tail bytes in frames generated by compress (outgoing)
      Returns:
      either TAIL_DROP_ALWAYS, TAIL_DROP_FIN_ONLY, or TAIL_DROP_NEVER
    • getRsvUseMode

      abstract int getRsvUseMode()
      Return the mode of operation for RSV flag use in frames generate by compress (outgoing)
      Returns:
      either RSV_USE_ALWAYS or RSV_USE_ONLY_FIRST
    • forwardIncoming

      protected void forwardIncoming(Frame frame, ByteAccumulator accumulator)
    • newByteAccumulator

      protected ByteAccumulator newByteAccumulator()
    • decompress

      protected void decompress(ByteAccumulator accumulator, ByteBuffer buf) throws DataFormatException
      Throws:
      DataFormatException
    • outgoingFrame

      public void outgoingFrame(Frame frame, WriteCallback callback, BatchMode batchMode)
      Description copied from interface: OutgoingFrames
      A frame, and optional callback, intended for the network layer.

      Note: the frame can undergo many transformations in the various layers and extensions present in the implementation.

      If you are implementing a mutation, you are obliged to handle the incoming WriteCallback appropriately.

      Parameters:
      frame - the frame to eventually write to the network layer.
      callback - the callback to notify when the frame is written.
      batchMode - the batch mode requested by the sender.
    • offerEntry

      private void offerEntry(CompressExtension.FrameEntry entry)
    • pollEntry

      private CompressExtension.FrameEntry pollEntry()
    • notifyCallbackSuccess

      protected void notifyCallbackSuccess(WriteCallback callback)
    • notifyCallbackFailure

      protected void notifyCallbackFailure(WriteCallback callback, Throwable failure)
    • supplyInput

      private static boolean supplyInput(Inflater inflater, ByteBuffer buf)
    • supplyInput

      private static boolean supplyInput(Deflater deflater, ByteBuffer buf)
    • toDetail

      private static String toDetail(Inflater inflater)
    • toDetail

      private static String toDetail(Deflater deflater)
    • endsWithTail

      public static boolean endsWithTail(ByteBuffer buf)
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.AbstractLifeCycle
      Throws:
      Exception
    • toString

      public String toString()
      Overrides:
      toString in class AbstractExtension