Adds is_server detection flag to deflate extension init

This commit is contained in:
Peter Thorson committed 2013-07-08 16:15:45 -05:00
1 parent c60e089553
commit 11906dc2ce
4 files changed
+14 -9

No files matched your search

+3 -3
View File
@@ -507,7 +507,7 @@ BOOST_AUTO_TEST_CASE( compress_data ) {
std::string compress_out;
std::string decompress_out;
v.exts.init();
v.exts.init(true);
v.ec = v.exts.compress(compress_in,compress_out);
BOOST_CHECK_EQUAL( v.ec, websocketpp::lib::error_code() );
@@ -520,7 +520,7 @@ BOOST_AUTO_TEST_CASE( compress_data ) {
BOOST_AUTO_TEST_CASE( compress_data_multiple ) {
ext_vars v;
v.exts.init();
v.exts.init(true);
for (int i = 0; i < 2; i++) {
std::string compress_in = "Hello";
@@ -550,7 +550,7 @@ BOOST_AUTO_TEST_CASE( decompress_data ) {
std::string out = "";
std::string reference = "Hello";
v.exts.init();
v.exts.init(true);
v.ec = v.exts.decompress(in,11,out);
@@ -58,7 +58,7 @@ public:
}
/// Initialize state
lib::error_code init() {
lib::error_code init(bool is_server) {
return lib::error_code();
}
@@ -49,7 +49,7 @@ namespace extensions {
* ### permessage-deflate interface
*
* **init**\n
* `lib::error_code init()`\n
* `lib::error_code init(bool is_server)`\n
* Performs initialization
*
* **is_implimented**\n
@@ -246,15 +246,20 @@ public:
/// 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
* @todo server detection is hardcoded
*
* @param is_server Whether or not to initialize as a server or client.
* @return A code representing the error that occurred, if any
*/
lib::error_code init() {
lib::error_code init(bool is_server) {
uint8_t deflate_bits;
uint8_t inflate_bits;
if (true /*is_server*/) {
if (is_server) {
deflate_bits = m_s2c_max_window_bits;
inflate_bits = m_c2s_max_window_bits;
} else {
+1 -1
View File
@@ -127,7 +127,7 @@ public:
// Note: this list will need commas if WebSocket++ ever
// supports more than one extension
ret.second += neg_ret.second;
m_permessage_deflate.init();
m_permessage_deflate.init(base::m_server);
continue;
}
}