Class PerMessageDeflateExtension
- java.lang.Object
-
- org.java_websocket.extensions.DefaultExtension
-
- org.java_websocket.extensions.CompressionExtension
-
- org.java_websocket.extensions.permessage_deflate.PerMessageDeflateExtension
-
- All Implemented Interfaces:
IExtension
public class PerMessageDeflateExtension extends CompressionExtension
PerMessage Deflate Extension (7. The "permessage-deflate" Extension in RFC 7692).
-
-
Field Summary
Fields Modifier and Type Field Description private static intBUFFER_SIZEprivate static java.lang.StringCLIENT_MAX_WINDOW_BITSprivate static java.lang.StringCLIENT_NO_CONTEXT_TAKEOVERprivate static intclientMaxWindowBitsprivate booleanclientNoContextTakeoverprivate java.util.zip.Deflaterdeflaterprivate static java.lang.StringEXTENSION_REGISTERED_NAMEprivate java.util.zip.Inflaterinflaterprivate java.util.Map<java.lang.String,java.lang.String>requestedParametersprivate static java.lang.StringSERVER_MAX_WINDOW_BITSprivate static java.lang.StringSERVER_NO_CONTEXT_TAKEOVERprivate static intserverMaxWindowBitsprivate booleanserverNoContextTakeoverprivate static byte[]TAIL_BYTES
-
Constructor Summary
Constructors Constructor Description PerMessageDeflateExtension()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptProvidedExtensionAsClient(java.lang.String inputExtension)Check if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a clientbooleanacceptProvidedExtensionAsServer(java.lang.String inputExtension)Check if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a serverIExtensioncopyInstance()Extensions must only be by one websocket at all.voiddecodeFrame(Framedata inputFrame)Decode a frame with a extension specific algorithm.private voiddecompress(byte[] data, java.io.ByteArrayOutputStream outputBuffer)voidencodeFrame(Framedata inputFrame)Encode a frame with a extension specific algorithm.private static booleanendsWithTail(byte[] data)java.util.zip.DeflatergetDeflater()java.util.zip.InflatergetInflater()java.lang.StringgetProvidedExtensionAsClient()Return the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a client.java.lang.StringgetProvidedExtensionAsServer()Return the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a server.booleanisClientNoContextTakeover()Access the "client_no_context_takeover" extension parametervoidisFrameValid(Framedata inputFrame)This extension requires the RSV1 bit to be set only for the first frame.booleanisServerNoContextTakeover()Access the "server_no_context_takeover" extension parametervoidsetClientNoContextTakeover(boolean clientNoContextTakeover)Setter for the "client_no_context_takeover" extension parametervoidsetDeflater(java.util.zip.Deflater deflater)voidsetInflater(java.util.zip.Inflater inflater)voidsetServerNoContextTakeover(boolean serverNoContextTakeover)Setter for the "server_no_context_takeover" extension parameterjava.lang.StringtoString()Return a string which should contain the class name as well as additional information about the current configurations for this extension (DEBUG purposes)-
Methods inherited from class org.java_websocket.extensions.DefaultExtension
equals, hashCode, reset
-
-
-
-
Field Detail
-
EXTENSION_REGISTERED_NAME
private static final java.lang.String EXTENSION_REGISTERED_NAME
- See Also:
- Constant Field Values
-
SERVER_NO_CONTEXT_TAKEOVER
private static final java.lang.String SERVER_NO_CONTEXT_TAKEOVER
- See Also:
- Constant Field Values
-
CLIENT_NO_CONTEXT_TAKEOVER
private static final java.lang.String CLIENT_NO_CONTEXT_TAKEOVER
- See Also:
- Constant Field Values
-
SERVER_MAX_WINDOW_BITS
private static final java.lang.String SERVER_MAX_WINDOW_BITS
- See Also:
- Constant Field Values
-
CLIENT_MAX_WINDOW_BITS
private static final java.lang.String CLIENT_MAX_WINDOW_BITS
- See Also:
- Constant Field Values
-
serverMaxWindowBits
private static final int serverMaxWindowBits
- See Also:
- Constant Field Values
-
clientMaxWindowBits
private static final int clientMaxWindowBits
- See Also:
- Constant Field Values
-
TAIL_BYTES
private static final byte[] TAIL_BYTES
-
BUFFER_SIZE
private static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
serverNoContextTakeover
private boolean serverNoContextTakeover
-
clientNoContextTakeover
private boolean clientNoContextTakeover
-
requestedParameters
private java.util.Map<java.lang.String,java.lang.String> requestedParameters
-
inflater
private java.util.zip.Inflater inflater
-
deflater
private java.util.zip.Deflater deflater
-
-
Method Detail
-
getInflater
public java.util.zip.Inflater getInflater()
-
setInflater
public void setInflater(java.util.zip.Inflater inflater)
-
getDeflater
public java.util.zip.Deflater getDeflater()
-
setDeflater
public void setDeflater(java.util.zip.Deflater deflater)
-
isServerNoContextTakeover
public boolean isServerNoContextTakeover()
Access the "server_no_context_takeover" extension parameter- Returns:
- serverNoContextTakeover is the server no context parameter active
- See Also:
- The "server_no_context_takeover" Extension Parameter
-
setServerNoContextTakeover
public void setServerNoContextTakeover(boolean serverNoContextTakeover)
Setter for the "server_no_context_takeover" extension parameter- Parameters:
serverNoContextTakeover- set the server no context parameter- See Also:
- The "server_no_context_takeover" Extension Parameter
-
isClientNoContextTakeover
public boolean isClientNoContextTakeover()
Access the "client_no_context_takeover" extension parameter- Returns:
- clientNoContextTakeover is the client no context parameter active
- See Also:
- The "client_no_context_takeover" Extension Parameter
-
setClientNoContextTakeover
public void setClientNoContextTakeover(boolean clientNoContextTakeover)
Setter for the "client_no_context_takeover" extension parameter- Parameters:
clientNoContextTakeover- set the client no context parameter- See Also:
- The "client_no_context_takeover" Extension Parameter
-
decodeFrame
public void decodeFrame(Framedata inputFrame) throws InvalidDataException
Description copied from interface:IExtensionDecode a frame with a extension specific algorithm. The algorithm is subject to be implemented by the specific extension. The resulting frame will be used in the application- Specified by:
decodeFramein interfaceIExtension- Overrides:
decodeFramein classDefaultExtension- Parameters:
inputFrame- the frame, which has do be decoded to be used in the application- Throws:
InvalidDataException- Throw InvalidDataException if the received frame is not correctly implemented by the other endpoint or there are other protocol errors/decoding errors
-
decompress
private void decompress(byte[] data, java.io.ByteArrayOutputStream outputBuffer) throws java.util.zip.DataFormatException- Parameters:
data- the bytes of dataoutputBuffer- the output stream- Throws:
java.util.zip.DataFormatException
-
encodeFrame
public void encodeFrame(Framedata inputFrame)
Description copied from interface:IExtensionEncode a frame with a extension specific algorithm. The algorithm is subject to be implemented by the specific extension. The resulting frame will be send to the other endpoint.- Specified by:
encodeFramein interfaceIExtension- Overrides:
encodeFramein classDefaultExtension- Parameters:
inputFrame- the frame, which has do be encoded to be used on the other endpoint
-
endsWithTail
private static boolean endsWithTail(byte[] data)
- Parameters:
data- the bytes of data- Returns:
- true if the data is OK
-
acceptProvidedExtensionAsServer
public boolean acceptProvidedExtensionAsServer(java.lang.String inputExtension)
Description copied from interface:IExtensionCheck if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a server- Specified by:
acceptProvidedExtensionAsServerin interfaceIExtension- Overrides:
acceptProvidedExtensionAsServerin classDefaultExtension- Parameters:
inputExtension- the received Sec-WebSocket-Extensions header field offered by the other endpoint- Returns:
- true, if the offer does fit to this specific extension
-
acceptProvidedExtensionAsClient
public boolean acceptProvidedExtensionAsClient(java.lang.String inputExtension)
Description copied from interface:IExtensionCheck if the received Sec-WebSocket-Extensions header field contains a offer for the specific extension if the endpoint is in the role of a client- Specified by:
acceptProvidedExtensionAsClientin interfaceIExtension- Overrides:
acceptProvidedExtensionAsClientin classDefaultExtension- Parameters:
inputExtension- the received Sec-WebSocket-Extensions header field offered by the other endpoint- Returns:
- true, if the offer does fit to this specific extension
-
getProvidedExtensionAsClient
public java.lang.String getProvidedExtensionAsClient()
Description copied from interface:IExtensionReturn the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a client. If the extension returns an empty string (""), the offer will not be included in the handshake.- Specified by:
getProvidedExtensionAsClientin interfaceIExtension- Overrides:
getProvidedExtensionAsClientin classDefaultExtension- Returns:
- the specific Sec-WebSocket-Extensions header for this extension
-
getProvidedExtensionAsServer
public java.lang.String getProvidedExtensionAsServer()
Description copied from interface:IExtensionReturn the specific Sec-WebSocket-Extensions header offer for this extension if the endpoint is in the role of a server. If the extension returns an empty string (""), the offer will not be included in the handshake.- Specified by:
getProvidedExtensionAsServerin interfaceIExtension- Overrides:
getProvidedExtensionAsServerin classDefaultExtension- Returns:
- the specific Sec-WebSocket-Extensions header for this extension
-
copyInstance
public IExtension copyInstance()
Description copied from interface:IExtensionExtensions must only be by one websocket at all. To prevent extensions to be used more than once the Websocket implementation should call this method in order to create a new usable version of a given extension instance.
The copy can be safely used in conjunction with a new websocket connection.- Specified by:
copyInstancein interfaceIExtension- Overrides:
copyInstancein classDefaultExtension- Returns:
- a copy of the extension
-
isFrameValid
public void isFrameValid(Framedata inputFrame) throws InvalidDataException
This extension requires the RSV1 bit to be set only for the first frame. If the frame is type is CONTINUOUS, RSV1 bit must be unset.- Specified by:
isFrameValidin interfaceIExtension- Overrides:
isFrameValidin classCompressionExtension- Parameters:
inputFrame- the received frame- Throws:
InvalidDataException- Throw InvalidDataException if the received frame is not correctly implementing the specification for the specific extension
-
toString
public java.lang.String toString()
Description copied from interface:IExtensionReturn a string which should contain the class name as well as additional information about the current configurations for this extension (DEBUG purposes)- Specified by:
toStringin interfaceIExtension- Overrides:
toStringin classDefaultExtension- Returns:
- a string containing the class name as well as additional information
-
-