Emit 1006 with some usable reason messages

This commit is contained in:
Alex Hultman
2020-06-27 01:49:51 +02:00
parent 13e0a93441
commit 3e5d91418a
2 changed files with 19 additions and 10 deletions
+9 -1
View File
@@ -21,9 +21,17 @@
#include <cstdint>
#include <cstring>
#include <cstdlib>
#include <string_view>
namespace uWS {
/* We should not overcomplicate these */
const std::string_view ERR_TOO_BIG_MESSAGE("Received too big message");
const std::string_view ERR_WEBSOCKET_TIMEOUT("WebSocket timed out from inactivity");
const std::string_view ERR_INVALID_TEXT("Received invalid UTF-8");
const std::string_view ERR_TOO_BIG_MESSAGE_INFLATION("Received too big message, or other inflation error");
const std::string_view ERR_INVALID_CLOSE_PAYLOAD("Received invalid close payload");
enum OpCode : unsigned char {
TEXT = 1,
BINARY = 2,
@@ -310,7 +318,7 @@ protected:
wState->state.lastFin = isFin(src);
if (Impl::refusePayloadLength(payLength, wState, user)) {
Impl::forceClose(wState, user);
Impl::forceClose(wState, user, ERR_TOO_BIG_MESSAGE);
return true;
}