Merge branch 'feature/add_status_code_check' into 'master'

esp_https_ota: Add check for HTTP error codes

Closes IDFGH-3593

See merge request espressif/esp-idf!9486
This commit is contained in:
Mahavir Jain 2020-07-08 13:12:46 +08:00
commit 5341688c7e
4 changed files with 14 additions and 3 deletions

View file

@ -142,7 +142,12 @@ typedef enum {
HttpStatus_TemporaryRedirect = 307,
/* 4xx - Client Error */
HttpStatus_Unauthorized = 401
HttpStatus_Unauthorized = 401,
HttpStatus_Forbidden = 403,
HttpStatus_NotFound = 404,
/* 5xx - Server Error */
HttpStatus_InternalError = 500
} HttpStatus_Code;
#define ESP_ERR_HTTP_BASE (0x7000) /*!< Starting number of HTTP error codes */

View file

@ -68,6 +68,12 @@ static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client
}
} else if (status_code == HttpStatus_Unauthorized) {
esp_http_client_add_auth(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);
return ESP_FAIL;
}
char upgrade_data_buf[DEFAULT_OTA_BUF_SIZE];

View file

@ -1,4 +1,4 @@
CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL="FROM_STDIN"
CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y
CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y
CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=2000
CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000

View file

@ -1,4 +1,4 @@
CONFIG_EXAMPLE_FIRMWARE_UPG_URL="FROM_STDIN"
CONFIG_EXAMPLE_SKIP_COMMON_NAME_CHECK=y
CONFIG_EXAMPLE_SKIP_VERSION_CHECK=y
CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=2000
CONFIG_EXAMPLE_OTA_RECV_TIMEOUT=3000