NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
websocketpp::extensions::permessage_deflate::enabled< config > Class Template Reference

#include <enabled.hpp>

Public Member Functions

 enabled ()
 
 ~enabled ()
 
lib::error_code init (bool is_server)
 Initialize zlib state. More...
 
bool is_implemented () const
 Test if this object implements the permessage-deflate specification. More...
 
bool is_enabled () const
 Test if the extension was negotiated for this connection. More...
 
void enable_server_no_context_takeover ()
 Reset server's outgoing LZ77 sliding window for each new message. More...
 
void enable_client_no_context_takeover ()
 Reset client's outgoing LZ77 sliding window for each new message. More...
 
lib::error_code set_server_max_window_bits (uint8_t bits, mode::value mode)
 Limit server LZ77 sliding window size. More...
 
lib::error_code set_client_max_window_bits (uint8_t bits, mode::value mode)
 Limit client LZ77 sliding window size. More...
 
std::string generate_offer () const
 Generate extension offer. More...
 
lib::error_code validate_offer (http::attribute_list const &)
 Validate extension response. More...
 
err_str_pair negotiate (http::attribute_list const &offer)
 Negotiate extension. More...
 
lib::error_code compress (std::string const &in, std::string &out)
 Compress bytes. More...
 
lib::error_code decompress (uint8_t const *buf, size_t len, std::string &out)
 Decompress bytes. More...
 

Detailed Description

template<typename config>
class websocketpp::extensions::permessage_deflate::enabled< config >

Definition at line 205 of file enabled.hpp.

Constructor & Destructor Documentation

template<typename config >
websocketpp::extensions::permessage_deflate::enabled< config >::enabled ( )
inline

Definition at line 207 of file enabled.hpp.

template<typename config >
websocketpp::extensions::permessage_deflate::enabled< config >::~enabled ( )
inline

Definition at line 229 of file enabled.hpp.

Member Function Documentation

template<typename config >
lib::error_code websocketpp::extensions::permessage_deflate::enabled< config >::init ( bool  is_server)
inline

Initialize zlib state.

Note: this should be called after the negotiation methods. It will use information from the negotiation to determine how to initialize the zlib data structures.

Todo:
memory level, strategy, etc are hardcoded
Parameters
is_serverTrue to initialize as a server, false for a client.
Returns
A code representing the error that occurred, if any

Definition at line 260 of file enabled.hpp.

References websocketpp::extensions::permessage_deflate::error::make_error_code(), and websocketpp::extensions::permessage_deflate::error::zlib_error.

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
bool websocketpp::extensions::permessage_deflate::enabled< config >::is_implemented ( ) const
inline

Test if this object implements the permessage-deflate specification.

Because this object does implieent it, it will always return true.

Returns
Whether or not this object implements permessage-deflate

Definition at line 312 of file enabled.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
bool websocketpp::extensions::permessage_deflate::enabled< config >::is_enabled ( ) const
inline

Test if the extension was negotiated for this connection.

Retrieves whether or not this extension is in use based on the initial handshake extension negotiations.

Returns
Whether or not the extension is in use

Definition at line 323 of file enabled.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
void websocketpp::extensions::permessage_deflate::enabled< config >::enable_server_no_context_takeover ( )
inline

Reset server's outgoing LZ77 sliding window for each new message.

Enabling this setting will cause the server's compressor to reset the compression state (the LZ77 sliding window) for every message. This means that the compressor will not look back to patterns in previous messages to improve compression. This will reduce the compression efficiency for large messages somewhat and small messages drastically.

This option may reduce server compressor memory usage and client decompressor memory usage.

Todo:
Document to what extent memory usage will be reduced

For clients, this option is dependent on server support. Enabling it via this method does not guarantee that it will be successfully negotiated, only that it will be requested.

For servers, no client support is required. Enabling this option on a server will result in its use. The server will signal to clients that the option will be in use so they can optimize resource usage if they are able.

Definition at line 348 of file enabled.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
void websocketpp::extensions::permessage_deflate::enabled< config >::enable_client_no_context_takeover ( )
inline

Reset client's outgoing LZ77 sliding window for each new message.

Enabling this setting will cause the client's compressor to reset the compression state (the LZ77 sliding window) for every message. This means that the compressor will not look back to patterns in previous messages to improve compression. This will reduce the compression efficiency for large messages somewhat and small messages drastically.

This option may reduce client compressor memory usage and server decompressor memory usage.

Todo:
Document to what extent memory usage will be reduced

This option is supported by all compliant clients and servers. Enabling it via either endpoint should be sufficient to ensure it is used.

Definition at line 367 of file enabled.hpp.

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
lib::error_code websocketpp::extensions::permessage_deflate::enabled< config >::set_server_max_window_bits ( uint8_t  bits,
mode::value  mode 
)
inline

Limit server LZ77 sliding window size.

The bits setting is the base 2 logarithm of the maximum window size that the server must use to compress outgoing messages. The permitted range is 8 to 15 inclusive. 8 represents a 256 byte window and 15 a 32KiB window. The default setting is 15.

Mode Options:

  • accept: Accept whatever the remote endpoint offers.
  • decline: Decline any offers to deviate from the defaults
  • largest: Accept largest window size acceptable to both endpoints
  • smallest: Accept smallest window size acceptiable to both endpoints

This setting is dependent on server support. A client requesting this setting may be rejected by the server or have the exact value used adjusted by the server. A server may unilaterally set this value without client support.

Parameters
bitsThe size to request for the outgoing window size
modeThe mode to use for negotiating this parameter
Returns
A status code

Definition at line 393 of file enabled.hpp.

References websocketpp::extensions::permessage_deflate::error::invalid_max_window_bits, and websocketpp::extensions::permessage_deflate::error::make_error_code().

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
lib::error_code websocketpp::extensions::permessage_deflate::enabled< config >::set_client_max_window_bits ( uint8_t  bits,
mode::value  mode 
)
inline

Limit client LZ77 sliding window size.

The bits setting is the base 2 logarithm of the window size that the client must use to compress outgoing messages. The permitted range is 8 to 15 inclusive. 8 represents a 256 byte window and 15 a 32KiB window. The default setting is 15.

Mode Options:

  • accept: Accept whatever the remote endpoint offers.
  • decline: Decline any offers to deviate from the defaults
  • largest: Accept largest window size acceptable to both endpoints
  • smallest: Accept smallest window size acceptiable to both endpoints

This setting is dependent on client support. A client may limit its own outgoing window size unilaterally. A server may only limit the client's window size if the remote client supports that feature.

Parameters
bitsThe size to request for the outgoing window size
modeThe mode to use for negotiating this parameter
Returns
A status code

Definition at line 424 of file enabled.hpp.

References websocketpp::extensions::permessage_deflate::error::invalid_max_window_bits, and websocketpp::extensions::permessage_deflate::error::make_error_code().

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
std::string websocketpp::extensions::permessage_deflate::enabled< config >::generate_offer ( ) const
inline

Generate extension offer.

Creates an offer string to include in the Sec-WebSocket-Extensions header of outgoing client requests.

Returns
A WebSocket extension offer string for this extension

Definition at line 441 of file enabled.hpp.

template<typename config >
lib::error_code websocketpp::extensions::permessage_deflate::enabled< config >::validate_offer ( http::attribute_list const &  )
inline

Validate extension response.

Confirm that the server has negotiated settings compatible with our original offer and apply those settings to the extension state.

Parameters
responseThe server response attribute list to validate
Returns
Validation error or 0 on success

Definition at line 454 of file enabled.hpp.

template<typename config >
err_str_pair websocketpp::extensions::permessage_deflate::enabled< config >::negotiate ( http::attribute_list const &  offer)
inline

Negotiate extension.

Confirm that the client's extension negotiation offer has settings compatible with local policy. If so, generate a reply and apply those settings to the extension state.

Parameters
offerAttribute from client's offer
Returns
Status code and value to return to remote endpoint

Definition at line 467 of file enabled.hpp.

References websocketpp::extensions::permessage_deflate::error::invalid_attributes, and websocketpp::extensions::permessage_deflate::error::make_error_code().

Referenced by BOOST_AUTO_TEST_CASE().

template<typename config >
lib::error_code websocketpp::extensions::permessage_deflate::enabled< config >::compress ( std::string const &  in,
std::string &  out 
)
inline

Compress bytes.

Todo:
: avail_in/out is 32 bit, need to fix for cases of >32 bit frames on 64 bit machines.
Parameters
[in]inString to compress
[out]outString to append compressed bytes to
Returns
Error or status code

Definition at line 506 of file enabled.hpp.

References websocketpp::extensions::permessage_deflate::error::make_error_code(), and websocketpp::extensions::permessage_deflate::error::uninitialized.

Referenced by BOOST_AUTO_TEST_CASE().


The documentation for this class was generated from the following file: