diff --git a/include/crow/routing.h b/include/crow/routing.h index 9365160ac..6757df3c7 100644 --- a/include/crow/routing.h +++ b/include/crow/routing.h @@ -391,13 +391,12 @@ namespace crow void handle_upgrade(const request& req, response&, SocketAdaptor&& adaptor) override { - auto* conn = new crow::websocket::Connection(req, std::move(adaptor), app_, open_handler_, message_handler_, close_handler_, error_handler_, accept_handler_); - conn->set_max_payload_size(max_payload_); + auto* conn = new crow::websocket::Connection(req, std::move(adaptor), max_payload_, max_, open_handler_, message_handler_, close_handler_, error_handler_, accept_handler_); } #ifdef CROW_ENABLE_SSL void handle_upgrade(const request& req, response&, SSLAdaptor&& adaptor) override { - new crow::websocket::Connection(req, std::move(adaptor), app_, open_handler_, message_handler_, close_handler_, error_handler_, accept_handler_); + new crow::websocket::Connection(req, std::move(adaptor), app_, max_payload_, open_handler_, message_handler_, close_handler_, error_handler_, accept_handler_); } #endif diff --git a/include/crow/websocket.h b/include/crow/websocket.h index fa0a0977c..43c7e6cec 100644 --- a/include/crow/websocket.h +++ b/include/crow/websocket.h @@ -69,7 +69,7 @@ namespace crow /// /// Requires a request with an "Upgrade: websocket" header.
/// Automatically handles the handshake. - Connection(const crow::request& req, Adaptor&& adaptor, Handler* handler, + Connection(const crow::request& req, Adaptor&& adaptor, Handler* handler, uint64_t max_payload, std::function open_handler, std::function message_handler, std::function close_handler, @@ -82,7 +82,7 @@ namespace crow close_handler_(std::move(close_handler)), error_handler_(std::move(error_handler)), accept_handler_(std::move(accept_handler)), - max_payload_bytes_(handler->websocket_max_payload()) + max_payload_bytes_(max_payload) { if (!boost::iequals(req.get_header_value("upgrade"), "websocket")) {