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:
parent
594cec54bd
commit
5f6fd238b6
|
@ -657,6 +657,7 @@ static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
|
||||||
switch (client->response->status_code) {
|
switch (client->response->status_code) {
|
||||||
case HttpStatus_MovedPermanently:
|
case HttpStatus_MovedPermanently:
|
||||||
case HttpStatus_Found:
|
case HttpStatus_Found:
|
||||||
|
case HttpStatus_TemporaryRedirect:
|
||||||
esp_http_client_set_redirection(client);
|
esp_http_client_set_redirection(client);
|
||||||
client->redirect_counter ++;
|
client->redirect_counter ++;
|
||||||
client->process_again = 1;
|
client->process_again = 1;
|
||||||
|
|
|
@ -131,6 +131,7 @@ typedef enum {
|
||||||
/* 3xx - Redirection */
|
/* 3xx - Redirection */
|
||||||
HttpStatus_MovedPermanently = 301,
|
HttpStatus_MovedPermanently = 301,
|
||||||
HttpStatus_Found = 302,
|
HttpStatus_Found = 302,
|
||||||
|
HttpStatus_TemporaryRedirect = 307,
|
||||||
|
|
||||||
/* 4xx - Client Error */
|
/* 4xx - Client Error */
|
||||||
HttpStatus_Unauthorized = 401
|
HttpStatus_Unauthorized = 401
|
||||||
|
|
|
@ -47,6 +47,7 @@ static bool process_again(int status_code)
|
||||||
switch (status_code) {
|
switch (status_code) {
|
||||||
case HttpStatus_MovedPermanently:
|
case HttpStatus_MovedPermanently:
|
||||||
case HttpStatus_Found:
|
case HttpStatus_Found:
|
||||||
|
case HttpStatus_TemporaryRedirect:
|
||||||
case HttpStatus_Unauthorized:
|
case HttpStatus_Unauthorized:
|
||||||
return true;
|
return true;
|
||||||
default:
|
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)
|
static esp_err_t _http_handle_response_code(esp_http_client_handle_t http_client, int status_code)
|
||||||
{
|
{
|
||||||
esp_err_t err;
|
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);
|
err = esp_http_client_set_redirection(http_client);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "URL redirection Failed");
|
ESP_LOGE(TAG, "URL redirection Failed");
|
||||||
|
|
Loading…
Reference in a new issue