PerMessageDeflate (Apache Tomcat 11.0.24 API Documentation)
Description: declaration: package: org.apache.tomcat.websocket, class: PerMessageDeflate

# Class PerMessageDeflate

java.lang.Object
org.apache.tomcat.websocket.PerMessageDeflate

All Implemented Interfaces:
  `Transformation`

public class PerMessageDeflate extends Object implements Transformation
Implementation of the permessage-deflate WebSocket extension as defined in RFC 7692. This extension provides message compression for WebSocket frames.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final TransformationBuilder`
  `BUILDER`
  The builder for the permessage-deflate transformation.
  `static final String`
  `NAME`
  The name of the permessage-deflate extension.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Clean-up any resources that were used by the transformation.
  `Extension`
  `getExtensionResponse()`
  Obtain the extension that describes the information to be returned to the client.
  `TransformationResult`
  `getMoreData(byte opCode, boolean fin, int rsv, ByteBuffer dest)`
  Obtain more input data.
  `List<MessagePart>`
  `sendMessagePart(List<MessagePart> uncompressedParts)`
  Takes the provided list of messages, transforms them, passes the transformed list on to the next transformation (if any) and then returns the resulting list of message parts after all of the transformations have been applied.
  `void`
  `setNext(Transformation t)`
  Sets the next transformation in the pipeline.
  `boolean`
  `validateRsv(int rsv, byte opCode)`
  Validates the RSV and opcode combination (assumed to have been extracted from a WebSocket Frame) for this extension.
  `boolean`
  `validateRsvBits(int i)`
  Validate that the RSV bit(s) required by this transformation are not being used by another extension.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### NAME

    public static final String NAME
    The name of the permessage-deflate extension.
    See Also:
      - Constant Field Values

  - ### BUILDER

    public static final TransformationBuilder BUILDER
    The builder for the permessage-deflate transformation.

- ## Method Details

  - ### getMoreData

    public TransformationResult getMoreData(byte opCode, boolean fin, int rsv, ByteBuffer dest) throws IOException
    Description copied from interface: `Transformation`
    Obtain more input data.
    Specified by:
      `getMoreData` in interface `Transformation`
    Parameters:
      `opCode` - The opcode for the frame currently being processed
      `fin` - Is this the final frame in this WebSocket message?
      `rsv` - The reserved bits for the frame currently being processed
      `dest` - The buffer in which the data is to be written
    Returns:
      The result of trying to read more data from the transform
    Throws:
      `IOException` - If an I/O error occurs while reading data from the transform

  - ### validateRsv

    public boolean validateRsv(int rsv, byte opCode)
    Description copied from interface: `Transformation`
    Validates the RSV and opcode combination (assumed to have been extracted from a WebSocket Frame) for this extension. The implementation is expected to unset any RSV bits it has validated before passing the remaining RSV bits to the next transformation in the pipeline.
    Specified by:
      `validateRsv` in interface `Transformation`
    Parameters:
      `rsv` - The RSV bits received as an int in the range zero to seven with RSV1 as the MSB and RSV3 as the LSB
      `opCode` - The opCode received
    Returns:
      `true` if the RSV is valid otherwise `false`

  - ### getExtensionResponse

    public Extension getExtensionResponse()
    Description copied from interface: `Transformation`
    Obtain the extension that describes the information to be returned to the client.
    Specified by:
      `getExtensionResponse` in interface `Transformation`
    Returns:
      The extension information that describes the parameters that have been agreed for this transformation

  - ### setNext

    public void setNext(Transformation t)
    Description copied from interface: `Transformation`
    Sets the next transformation in the pipeline.
    Specified by:
      `setNext` in interface `Transformation`
    Parameters:
      `t` - The next transformation

  - ### validateRsvBits

    public boolean validateRsvBits(int i)
    Description copied from interface: `Transformation`
    Validate that the RSV bit(s) required by this transformation are not being used by another extension. The implementation is expected to set any bits it requires before passing the set of in-use bits to the next transformation.
    Specified by:
      `validateRsvBits` in interface `Transformation`
    Parameters:
      `i` - The RSV bits marked as in use so far as an int in the range zero to seven with RSV1 as the MSB and RSV3 as the LSB
    Returns:
      `true` if the combination of RSV bits used by the transformations in the pipeline do not conflict otherwise `false`

  - ### sendMessagePart

    public List<MessagePart> sendMessagePart(List<MessagePart> uncompressedParts) throws IOException
    Description copied from interface: `Transformation`
    Takes the provided list of messages, transforms them, passes the transformed list on to the next transformation (if any) and then returns the resulting list of message parts after all of the transformations have been applied.
    Specified by:
      `sendMessagePart` in interface `Transformation`
    Parameters:
      `uncompressedParts` - The list of messages to be transformed
    Returns:
      The list of messages after this and any subsequent transformations have been applied. The size of the returned list may be bigger or smaller than the size of the input list
    Throws:
      `IOException` - If an error occurs during the transformation of the message parts

  - ### close

    public void close()
    Description copied from interface: `Transformation`
    Clean-up any resources that were used by the transformation.
    Specified by:
      `close` in interface `Transformation`