HTTP Server Examples : Updated examples to manually return 408 and 500 errors

This commit is contained in:
Anurag Kar
2018-10-09 18:07:38 +05:30
parent 1437646ae0
commit 6a3fa5c180
4 changed files with 40 additions and 19 deletions

View File

@@ -48,7 +48,10 @@ esp_err_t adder_post_handler(httpd_req_t *req)
/* Read data received in the request */
ret = httpd_req_recv(req, buf, sizeof(buf));
if (ret < 0) {
if (ret <= 0) {
if (ret == HTTPD_SOCK_ERR_TIMEOUT) {
httpd_resp_send_408(req);
}
return ESP_FAIL;
}
@@ -111,7 +114,10 @@ esp_err_t adder_put_handler(httpd_req_t *req)
/* Read data received in the request */
ret = httpd_req_recv(req, buf, sizeof(buf));
if (ret < 0) {
if (ret <= 0) {
if (ret == HTTPD_SOCK_ERR_TIMEOUT) {
httpd_resp_send_408(req);
}
return ESP_FAIL;
}