mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_http_client.h: Add error codes in HttpStatus_Code
esp_https_ota.c: Add checks for HTTP error codes Closes: https://github.com/espressif/esp-idf/issues/5537
This commit is contained in:
parent
ea75605aa7
commit
3c7991813d
@ -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 */
|
||||
|
@ -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];
|
||||
|
Loading…
x
Reference in New Issue
Block a user