Skip to content

Commit

Permalink
esp_https_ota: Add check for HTTP error codes and corresponding error…
Browse files Browse the repository at this point in the history
… logs

Closes: espressif#7058
  • Loading branch information
shubhamkulkarni97 authored and espressif-bot committed Jun 2, 2021
1 parent bdea007 commit 3064487
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions components/esp_http_client/include/esp_http_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ typedef enum {
HttpStatus_TemporaryRedirect = 307,

/* 4xx - Client Error */
HttpStatus_BadRequest = 400,
HttpStatus_Unauthorized = 401,
HttpStatus_Forbidden = 403,
HttpStatus_NotFound = 404,
Expand Down
7 changes: 5 additions & 2 deletions components/esp_https_ota/src/esp_https_ota.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client
} else if(status_code == HttpStatus_NotFound || status_code == HttpStatus_Forbidden) {
ESP_LOGE(TAG, "File not found(%d)", status_code);
return ESP_FAIL;
} else if (status_code == HttpStatus_InternalError) {
ESP_LOGE(TAG, "Server error occurred(%d)", status_code);
} else if (status_code >= HttpStatus_BadRequest && status_code < HttpStatus_InternalError) {
ESP_LOGE(TAG, "Client error (%d)", status_code);
return ESP_FAIL;
} else if (status_code >= HttpStatus_InternalError) {
ESP_LOGE(TAG, "Server error (%d)", status_code);
return ESP_FAIL;
}

Expand Down

0 comments on commit 3064487

Please sign in to comment.