Merge branch 'bugfix/fix_ws_handle_big_messages' into 'master'

esp_http_server: Fix ws server handle length over 1440(MTU) messages incorrectly.

Closes IDFGH-5740

See merge request espressif/esp-idf!14978
This commit is contained in:
Mahavir Jain 2021-08-31 05:24:52 +00:00
commit 148794f208

View File

@ -328,15 +328,19 @@ esp_err_t httpd_ws_recv_frame(httpd_req_t *req, httpd_ws_frame_t *frame, size_t
return ESP_FAIL;
}
int read_len = 0, left_len = frame->len;
size_t left_len = frame->len;
size_t offset = 0;
while (left_len > 0) {
if ((read_len = httpd_recv_with_opt(req, (char *)frame->payload + read_len, left_len, false)) <= 0) {
int read_len = httpd_recv_with_opt(req, (char *)frame->payload + offset, left_len, false);
if (read_len <= 0) {
ESP_LOGW(TAG, LOG_FMT("Failed to receive payload"));
return ESP_FAIL;
}
if (left_len -= read_len) {
ESP_LOGD(TAG, "recv data length is less than the data length we want. Read again!");
}
offset += read_len;
left_len -= read_len;
ESP_LOGD(TAG, "Frame length: %d, Bytes Read: %d", frame->len, offset);
}
/* Unmask payload */