mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_https_ota: Add check for 303 and 308 status code
Closes https://github.com/espressif/esp-idf/issues/8581
This commit is contained in:
parent
ec6f222625
commit
d5a8a57686
@ -51,12 +51,29 @@ struct esp_https_ota_handle {
|
||||
|
||||
typedef struct esp_https_ota_handle esp_https_ota_t;
|
||||
|
||||
static bool redirection_required(int status_code)
|
||||
{
|
||||
switch (status_code) {
|
||||
case HttpStatus_MovedPermanently:
|
||||
case HttpStatus_Found:
|
||||
case HttpStatus_SeeOther:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
case HttpStatus_PermanentRedirect:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool process_again(int status_code)
|
||||
{
|
||||
switch (status_code) {
|
||||
case HttpStatus_MovedPermanently:
|
||||
case HttpStatus_Found:
|
||||
case HttpStatus_SeeOther:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
case HttpStatus_PermanentRedirect:
|
||||
case HttpStatus_Unauthorized:
|
||||
return true;
|
||||
default:
|
||||
@ -68,7 +85,7 @@ static bool process_again(int status_code)
|
||||
static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client, int status_code)
|
||||
{
|
||||
esp_err_t err;
|
||||
if (status_code == HttpStatus_MovedPermanently || status_code == HttpStatus_Found || status_code == HttpStatus_TemporaryRedirect) {
|
||||
if (redirection_required(status_code)) {
|
||||
err = esp_http_client_set_redirection(http_client);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "URL redirection Failed");
|
||||
|
Loading…
Reference in New Issue
Block a user