WebSocketPerMessageDeflateCompressor

This commit is contained in:
Benjamin Sergeant 2020-07-07 10:59:59 -07:00
parent 7c1b57c8cd
commit f772e40ad8
2 changed files with 14 additions and 0 deletions

View File

@ -67,6 +67,16 @@ namespace ix
}
bool WebSocketPerMessageDeflateCompressor::compress(const std::string& in, std::string& out)
{
return compressData(in, out);
}
bool WebSocketPerMessageDeflateCompressor::compress(const std::vector<uint8_t>& in, std::string& out)
{
return compressData(in, out);
}
template<typename T, typename S> bool WebSocketPerMessageDeflateCompressor::compressData(const T& in, S& out)
{
//
// 7.2.1. Compression

View File

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