Top Fields Constructors Methods
org.apache.tomcat.websocket

public Class PerMessageDeflate

extends Object
implements Transformation
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.websocket.Transformation
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.ArrayList, .List, java.util.zip.DataFormatException, .Deflater, .Inflater, jakarta.websocket.Extension, .Extension.Parameter, .SendHandler, org.apache.tomcat.util.res.StringManager

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
private final boolean
private final int
private final Deflater
private volatile boolean
private final byte[]
private static final byte[]
private volatile boolean
private final Inflater
private final boolean
public static final String
private volatile Transformation
private final ByteBuffer
private static final int
private static final String
private static final String
private final boolean
private final int
private volatile boolean
private static final StringManager
private volatile ByteBuffer

Constructor Summary

AccessConstructor and Description
private
PerMessageDeflate(boolean serverContextTakeover, int serverMaxWindowBits, boolean clientContextTakeover, int clientMaxWindowBits, boolean isServer)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.apache.tomcat.websocket.Transformation.close.

Clean-up any resources that were used by the transformation.

public Extension
getExtensionResponse()

Implements org.apache.tomcat.websocket.Transformation.getExtensionResponse.

Obtain the extension that describes the information to be returned to the client.

public TransformationResult
getMoreData(byte
The opcode for the frame currently being processed
opCode
,
boolean
Is this the final frame in this WebSocket message?
fin
,
int
The reserved bits for the frame currently being processed
rsv
,
ByteBuffer
The buffer in which the data is to be written
dest
)

Implements org.apache.tomcat.websocket.Transformation.getMoreData.

Obtain more input data.

private int
getRsv(MessagePart uncompressedMessagePart)

pack-priv static PerMessageDeflate
negotiate(List<List<Extension.Parameter>> preferences, boolean isServer)

public List<MessagePart>
sendMessagePart(List<MessagePart>
The list of messages to be transformed
uncompressedParts
)

Implements org.apache.tomcat.websocket.Transformation.sendMessagePart.

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.

public void
setNext(Transformation
The next transformation
t
)

Implements org.apache.tomcat.websocket.Transformation.setNext.

Sets the next transformation in the pipeline.

private void
public boolean
validateRsv(int
The RSV bits received as an int in the range zero to seven with RSV1 as the MSB and RSV3 as the LSB
rsv
,
byte
The opCode received
opCode
)

Implements org.apache.tomcat.websocket.Transformation.validateRsv.

Validates the RSV and opcode combination (assumed to have been extracted from a WebSocket Frame) for this extension.

public boolean
validateRsvBits(int
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
i
)

Implements org.apache.tomcat.websocket.Transformation.validateRsvBits.

Validate that the RSV bit(s) required by this transformation are not being used by another extension.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CLIENT_MAX_WINDOW_BITSback to summary
private static final String CLIENT_MAX_WINDOW_BITS
CLIENT_NO_CONTEXT_TAKEOVERback to summary
private static final String CLIENT_NO_CONTEXT_TAKEOVER
clientContextTakeoverback to summary
private final boolean clientContextTakeover
clientMaxWindowBitsback to summary
private final int clientMaxWindowBits
deflaterback to summary
private final Deflater deflater
emptyMessageback to summary
private volatile boolean emptyMessage
EOM_BUFFERback to summary
private final byte[] EOM_BUFFER
EOM_BYTESback to summary
private static final byte[] EOM_BYTES
firstCompressedFrameWrittenback to summary
private volatile boolean firstCompressedFrameWritten
inflaterback to summary
private final Inflater inflater
isServerback to summary
private final boolean isServer
NAMEback to summary
public static final String NAME
nextback to summary
private volatile Transformation next
readBufferback to summary
private final ByteBuffer readBuffer
RSV_BITMASKback to summary
private static final int RSV_BITMASK
SERVER_MAX_WINDOW_BITSback to summary
private static final String SERVER_MAX_WINDOW_BITS
SERVER_NO_CONTEXT_TAKEOVERback to summary
private static final String SERVER_NO_CONTEXT_TAKEOVER
serverContextTakeoverback to summary
private final boolean serverContextTakeover
serverMaxWindowBitsback to summary
private final int serverMaxWindowBits
skipDecompressionback to summary
private volatile boolean skipDecompression
smback to summary
private static final StringManager sm
writeBufferback to summary
private volatile ByteBuffer writeBuffer

Constructor Detail

PerMessageDeflateback to summary
private PerMessageDeflate(boolean serverContextTakeover, int serverMaxWindowBits, boolean clientContextTakeover, int clientMaxWindowBits, boolean isServer)

Method Detail

closeback to summary
public void close()

Implements org.apache.tomcat.websocket.Transformation.close.

Doc from org.apache.tomcat.websocket.Transformation.close.

Clean-up any resources that were used by the transformation.

Annotations
@Override
getExtensionResponseback to summary
public Extension getExtensionResponse()

Implements org.apache.tomcat.websocket.Transformation.getExtensionResponse.

Doc from org.apache.tomcat.websocket.Transformation.getExtensionResponse.

Obtain the extension that describes the information to be returned to the client.

Returns:Extension

The extension information that describes the parameters that have been agreed for this transformation

Annotations
@Override
getMoreDataback to summary
public TransformationResult getMoreData(byte opCode, boolean fin, int rsv, ByteBuffer dest) throws IOException

Implements org.apache.tomcat.websocket.Transformation.getMoreData.

Doc from org.apache.tomcat.websocket.Transformation.getMoreData.

Obtain more input data.

Parameters
opCode:byte

The opcode for the frame currently being processed

fin:boolean

Is this the final frame in this WebSocket message?

rsv:int

The reserved bits for the frame currently being processed

dest:ByteBuffer

The buffer in which the data is to be written

Returns:TransformationResult

The result of trying to read more data from the transform

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs while reading data from the transform
getRsvback to summary
private int getRsv(MessagePart uncompressedMessagePart)
negotiateback to summary
pack-priv static PerMessageDeflate negotiate(List<List<Extension.Parameter>> preferences, boolean isServer)
sendMessagePartback to summary
public List<MessagePart> sendMessagePart(List<MessagePart> uncompressedParts) throws IOException

Implements org.apache.tomcat.websocket.Transformation.sendMessagePart.

Doc from org.apache.tomcat.websocket.Transformation.sendMessagePart.

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.

Parameters
uncompressedParts:List<MessagePart>

The list of messages to be transformed

Returns:List<MessagePart>

The list of messages after this any any subsequent transformations have been applied. The size of the returned list may be bigger or smaller than the size of the input list

Annotations
@Override
Exceptions
IOException:
If an error occurs during the transformation of the message parts
setNextback to summary
public void setNext(Transformation t)

Implements org.apache.tomcat.websocket.Transformation.setNext.

Doc from org.apache.tomcat.websocket.Transformation.setNext.

Sets the next transformation in the pipeline.

Parameters
t:Transformation

The next transformation

Annotations
@Override
startNewMessageback to summary
private void startNewMessage() throws IOException
validateRsvback to summary
public boolean validateRsv(int rsv, byte opCode)

Implements org.apache.tomcat.websocket.Transformation.validateRsv.

Doc from org.apache.tomcat.websocket.Transformation.validateRsv.

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.

Parameters
rsv:int

The RSV bits received as an int in the range zero to seven with RSV1 as the MSB and RSV3 as the LSB

opCode:byte

The opCode received

Returns:boolean

true if the RSV is valid otherwise false

Annotations
@Override
validateRsvBitsback to summary
public boolean validateRsvBits(int i)

Implements org.apache.tomcat.websocket.Transformation.validateRsvBits.

Doc from org.apache.tomcat.websocket.Transformation.validateRsvBits.

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.

Parameters
i:int

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:boolean

true if the combination of RSV bits used by the transformations in the pipeline do not conflict otherwise false

Annotations
@Override