Allow UWS_NO_ZLIB to work properly
This commit is contained in:
+2
-2
@@ -10,7 +10,7 @@ int main(int argc, char **argv) {
|
||||
int hello;
|
||||
};
|
||||
|
||||
uWS::SSLApp({
|
||||
uWS::/*SSL*/App({
|
||||
.key_file_name = "/home/alexhultman/key.pem",
|
||||
.cert_file_name = "/home/alexhultman/cert.pem",
|
||||
.passphrase = "1234"
|
||||
@@ -19,7 +19,7 @@ int main(int argc, char **argv) {
|
||||
}).ws<PerSocketData>("/*", {
|
||||
/* Settings */
|
||||
.compression = uWS::DEDICATED_COMPRESSOR,
|
||||
.maxPayloadLength = 16 * 1024,
|
||||
.maxPayloadLength = 16 * 1024 * 1024,
|
||||
/* Handlers */
|
||||
.open = [](auto *ws, auto *req) {
|
||||
std::cout << "WebSocket connected" << std::endl;
|
||||
|
||||
@@ -78,6 +78,11 @@ public:
|
||||
/* Every route has its own websocket context with its own behavior and user data type */
|
||||
auto *webSocketContext = WebSocketContext<SSL, true>::create(Loop::defaultLoop(), (typename StaticDispatch<SSL>::SOCKET_CONTEXT_TYPE *) httpContext);
|
||||
|
||||
/* Quick fix to disable any compression if set */
|
||||
#ifdef UWS_NO_ZLIB
|
||||
behavior.compression = uWS::DISABLED;
|
||||
#endif
|
||||
|
||||
/* If we are the first one to use compression, initialize it */
|
||||
if (behavior.compression) {
|
||||
LoopData *loopData = (LoopData *) us_loop_ext(static_dispatch(us_ssl_socket_context_loop, us_socket_context_loop)(webSocketContext->getSocketContext()));
|
||||
|
||||
+17
-1
@@ -19,7 +19,19 @@
|
||||
#ifndef PERMESSAGEDEFLATE_H
|
||||
#define PERMESSAGEDEFLATE_H
|
||||
/* Do not compile this module if we don't want it */
|
||||
#ifndef UWS_NO_ZLIB
|
||||
#ifdef UWS_NO_ZLIB
|
||||
struct ZlibContext {};
|
||||
struct InflationStream {
|
||||
std::string_view inflate(ZlibContext *zlibContext, std::string_view compressed, size_t maxPayloadLength) {
|
||||
return compressed;
|
||||
}
|
||||
};
|
||||
struct DeflationStream {
|
||||
std::string_view deflate(ZlibContext *zlibContext, std::string_view raw, bool reset) {
|
||||
return raw;
|
||||
}
|
||||
};
|
||||
#else
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
@@ -109,6 +121,10 @@ struct InflationStream {
|
||||
inflateInit2(&inflationStream, -15);
|
||||
}
|
||||
|
||||
~InflationStream() {
|
||||
std::cout << "Destructing inflationstream" << std::endl;
|
||||
}
|
||||
|
||||
std::string_view inflate(ZlibContext *zlibContext, std::string_view compressed, size_t maxPayloadLength) {
|
||||
|
||||
/* We clear this one here, could be done better */
|
||||
|
||||
Reference in New Issue
Block a user