WebSocketPerMessageDeflateCompressor can work with vector or std::string

This commit is contained in:
Benjamin Sergeant
2020-07-07 18:17:44 -07:00
parent e9e768a288
commit 95eab59c08
3 changed files with 65 additions and 9 deletions

View File

@ -9,6 +9,7 @@
#include "zlib.h"
#include <memory>
#include <string>
#include <vector>
namespace ix
{
@ -20,9 +21,13 @@ namespace ix
bool init(uint8_t deflateBits, bool clientNoContextTakeOver);
bool compress(const std::string& in, std::string& out);
bool compress(const std::string& in, std::vector<uint8_t>& out);
bool compress(const std::vector<uint8_t>& in, std::string& out);
bool compress(const std::vector<uint8_t>& in, std::vector<uint8_t>& out);
private:
static bool endsWith(const std::string& value, const std::string& ending);
template<typename T, typename S> bool compressData(const T& in, S& out);
template<typename T> bool endsWithEmptyUnCompressedBlock(const T& value);
int _flush;
size_t _compressBufferSize;