From 774d1c75e6e5c3cf8cb4e5a0763e1580bddfb104 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Tue, 19 Dec 2023 17:00:17 +0100 Subject: [PATCH] fix: continuation after FIN in websocket client (#460) --- components/esp_websocket_client/esp_websocket_client.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/esp_websocket_client/esp_websocket_client.c b/components/esp_websocket_client/esp_websocket_client.c index cfd036e041..3badfe76f9 100644 --- a/components/esp_websocket_client/esp_websocket_client.c +++ b/components/esp_websocket_client/esp_websocket_client.c @@ -551,9 +551,14 @@ static int esp_websocket_client_send_with_exact_opcode(esp_websocket_client_hand int need_write = len; int wlen = 0, widx = 0; + bool contained_fin = opcode & WS_TRANSPORT_OPCODES_FIN; + while (widx < len || opcode) { // allow for sending "current_opcode" only message with len==0 if (need_write > client->buffer_size) { need_write = client->buffer_size; + opcode = opcode & ~WS_TRANSPORT_OPCODES_FIN; + } else if (contained_fin) { + opcode = opcode | WS_TRANSPORT_OPCODES_FIN; } memcpy(client->tx_buffer, data + widx, need_write); // send with ws specific way and specific opcode