mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
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) {
|
||||
case HttpStatus_MovedPermanently:
|
||||
case HttpStatus_Found:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
esp_http_client_set_redirection(client);
|
||||
client->redirect_counter ++;
|
||||
client->process_again = 1;
|
||||
|
@ -131,6 +131,7 @@ typedef enum {
|
||||
/* 3xx - Redirection */
|
||||
HttpStatus_MovedPermanently = 301,
|
||||
HttpStatus_Found = 302,
|
||||
HttpStatus_TemporaryRedirect = 307,
|
||||
|
||||
/* 4xx - Client Error */
|
||||
HttpStatus_Unauthorized = 401
|
||||
|
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user