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

Closes https://github.com/espressif/esp-idf/issues/7202
This commit is contained in:
yuanjm 2021-07-02 10:49:31 +08:00
parent 2a747b7bb1
commit f2a0b48cf9

View File

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