Skip to content

Commit

Permalink
Update context.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
maddsua committed Feb 12, 2024
1 parent 2e3a809 commit 481286a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions core/websocket/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <cstring>

using namespace Lambda;
using namespace Lambda::HTTP;
using namespace Lambda::HTTP::Transport;
using namespace Lambda::Websocket;
using namespace Lambda::Websocket::Transport;

Expand All @@ -29,11 +31,11 @@ WebsocketContext::WebsocketContext(HTTP::Transport::TransportContext& tctx, cons
auto headerWsKey = initRequest.headers.get("Sec-WebSocket-Key");

if (headerUpgrade != "websocket" || !headerWsKey.size()) {
throw std::runtime_error("Websocket initialization aborted: Invalid connection header");
throw ProtocolError("Websocket initialization aborted: Invalid connection header", 400);
}

if (tctx.hasPartialData()) {
throw std::runtime_error("Websocket initialization aborted: Connection has unprocessed data");
throw ProtocolError("Websocket initialization aborted: Connection has unprocessed data", 400);
}

auto combinedKey = headerWsKey + wsMagicString;
Expand Down

0 comments on commit 481286a

Please sign in to comment.