Skip to content
Merged
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
21 changes: 17 additions & 4 deletions include/crow/websocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,15 @@ namespace crow
/// Reading the actual payload.<br>
void do_read()
{
if (has_sent_close_ && has_recv_close_)
{
close_connection_ = true;
adaptor_.shutdown_readwrite();
adaptor_.close();
check_destroy();
return;
}

is_reading = true;
switch (state_)
{
Expand Down Expand Up @@ -475,9 +484,11 @@ namespace crow
remaining_length_ -= bytes_transferred;
if (remaining_length_ == 0)
{
handle_fragment();
state_ = WebSocketReadState::MiniHeader;
do_read();
if (handle_fragment())
{
state_ = WebSocketReadState::MiniHeader;
do_read();
}
}
else
do_read();
Expand Down Expand Up @@ -513,7 +524,7 @@ namespace crow

///
/// Unmasks the fragment, checks the opcode, merges fragments into 1 message body, and calls the appropriate handler.
void handle_fragment()
bool handle_fragment()
{
if (has_mask_)
{
Expand Down Expand Up @@ -578,6 +589,7 @@ namespace crow
is_close_handler_called_ = true;
}
check_destroy();
return false;
}
}
break;
Expand All @@ -594,6 +606,7 @@ namespace crow
}

fragment_.clear();
return true;
}

/// Send the buffers' data through the socket.
Expand Down