fix: esp_http_client and esp_https_ota can follow 307 Redirects

Closes https://github.com/espressif/esp-idf/pull/4431
This commit is contained in:
Aidan Cyr 2019-11-29 14:17:51 +11:00 committed by Mahavir Jain
parent 594cec54bd
commit 5f6fd238b6
3 changed files with 4 additions and 1 deletions

View File

@ -657,6 +657,7 @@ static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
switch (client->response->status_code) {
case HttpStatus_MovedPermanently:
case HttpStatus_Found:
case HttpStatus_TemporaryRedirect:
esp_http_client_set_redirection(client);
client->redirect_counter ++;
client->process_again = 1;

View File

@ -131,6 +131,7 @@ typedef enum {
/* 3xx - Redirection */
HttpStatus_MovedPermanently = 301,
HttpStatus_Found = 302,
HttpStatus_TemporaryRedirect = 307,
/* 4xx - Client Error */
HttpStatus_Unauthorized = 401

View File

@ -47,6 +47,7 @@ static bool process_again(int status_code)
switch (status_code) {
case HttpStatus_MovedPermanently:
case HttpStatus_Found:
case HttpStatus_TemporaryRedirect:
case HttpStatus_Unauthorized:
return true;
default:
@ -58,7 +59,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) {
if (status_code == HttpStatus_MovedPermanently || status_code == HttpStatus_Found || status_code == HttpStatus_TemporaryRedirect) {
err = esp_http_client_set_redirection(http_client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "URL redirection Failed");