Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/HTTPConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,17 @@ void HTTPConnection::loop() {

// Finally, after the handshake is done, we create the WebsocketHandler and change the internal state.
if(websocketRequested) {
_wsHandler = ((WebsocketNode*)resolvedResource.getMatchingNode())->newHandler();
_wsHandler->initialize(this); // make websocket with this connection
_connectionState = STATE_WEBSOCKET;
HTTPNode *node = resolvedResource.getMatchingNode();

// Check for websocket request on non-websocket node:
if (node == nullptr || node->_nodeType != HTTPNodeType::WEBSOCKET) {
HTTPS_LOGW("Websocket request on non-websocket node rejected");
raiseError(404, "Not Found");
} else {
_wsHandler = ((WebsocketNode *) node)->newHandler();
_wsHandler->initialize(this); // make websocket with this connection
_connectionState = STATE_WEBSOCKET;
}
} else {
// Handling the request is done
HTTPS_LOGD("Handler function done, request complete");
Expand Down