file_server: fix issue with sending last chunk
Closes: https://github.com/espressif/esp-idf/issues/4528 Closes IDFGH-2414
This commit is contained in:
parent
c0d12988d3
commit
9ef8cafeca
|
@ -256,6 +256,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
||||||
/* Read file in chunks into the scratch buffer */
|
/* Read file in chunks into the scratch buffer */
|
||||||
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
|
chunksize = fread(chunk, 1, SCRATCH_BUFSIZE, fd);
|
||||||
|
|
||||||
|
if (chunksize > 0) {
|
||||||
/* Send the buffer contents as HTTP response chunk */
|
/* Send the buffer contents as HTTP response chunk */
|
||||||
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
|
if (httpd_resp_send_chunk(req, chunk, chunksize) != ESP_OK) {
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
@ -266,6 +267,7 @@ static esp_err_t download_get_handler(httpd_req_t *req)
|
||||||
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to send file");
|
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to send file");
|
||||||
return ESP_FAIL;
|
return ESP_FAIL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Keep looping till the whole file is sent */
|
/* Keep looping till the whole file is sent */
|
||||||
} while (chunksize != 0);
|
} while (chunksize != 0);
|
||||||
|
|
Loading…
Reference in a new issue