Skip to content

Commit aadda22

Browse files
authored
Merge pull request #461 from 0xFEEDC0DE64/fix-websocket-client-fin
fix(websocket): continuation after FIN in websocket client (#460) (IDFGH-11761)
2 parents a6845f4 + 774d1c7 commit aadda22

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

components/esp_websocket_client/esp_websocket_client.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,14 @@ static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_hand
551551
int need_write = len;
552552
int wlen = 0, widx = 0;
553553

554+
bool contained_fin = opcode & WS_TRANSPORT_OPCODES_FIN;
555+
554556
while (widx < len || opcode) { // allow for sending "current_opcode" only message with len==0
555557
if (need_write > client->buffer_size) {
556558
need_write = client->buffer_size;
559+
opcode = opcode & ~WS_TRANSPORT_OPCODES_FIN;
560+
} else if (contained_fin) {
561+
opcode = opcode | WS_TRANSPORT_OPCODES_FIN;
557562
}
558563
memcpy(client->tx_buffer, data + widx, need_write);
559564
// send with ws specific way and specific opcode

0 commit comments

Comments
 (0)