Skip to content

Commit

Permalink
Fix api not handling errors properly
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson committed Nov 5, 2024
1 parent da2d255 commit 953c9e1
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static esp_err_t rest_common_get_handler(httpd_req_t * req)
httpd_resp_sendstr_chunk(req, NULL);
/* Respond with 500 Internal Server Error */
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to send file");
return ESP_FAIL;
return ESP_OK;
}
}
} while (read_bytes > 0);
Expand All @@ -193,7 +193,6 @@ static esp_err_t rest_common_get_handler(httpd_req_t * req)
return ESP_OK;
}


static esp_err_t handle_options_request(httpd_req_t * req)
{
// Set CORS headers for OPTIONS request
Expand Down Expand Up @@ -223,14 +222,14 @@ static esp_err_t PATCH_update_settings(httpd_req_t * req)
if (total_len >= SCRATCH_BUFSIZE) {
/* Respond with 500 Internal Server Error */
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "content too long");
return ESP_FAIL;
return ESP_OK;
}
while (cur_len < total_len) {
received = httpd_req_recv(req, buf + cur_len, total_len);
if (received <= 0) {
/* Respond with 500 Internal Server Error */
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR, "Failed to post control value");
return ESP_FAIL;
return ESP_OK;
}
cur_len += received;
}
Expand Down

0 comments on commit 953c9e1

Please sign in to comment.