mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 12:44:33 +02:00
Merge branch 'bugfix/http_code' into 'master'
esp_http_client, esp_https_ota: Handle HTTP 303 status code Closes IDFGH-6961 See merge request espressif/esp-idf!17512
This commit is contained in:
@@ -821,7 +821,9 @@ 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_SeeOther:
|
||||
case HttpStatus_TemporaryRedirect:
|
||||
case HttpStatus_PermanentRedirect:
|
||||
if (client->disable_auto_redirect) {
|
||||
http_dispatch_event(client, HTTP_EVENT_REDIRECT, NULL, 0);
|
||||
}
|
||||
|
@@ -150,7 +150,9 @@ typedef enum {
|
||||
HttpStatus_MultipleChoices = 300,
|
||||
HttpStatus_MovedPermanently = 301,
|
||||
HttpStatus_Found = 302,
|
||||
HttpStatus_SeeOther = 303,
|
||||
HttpStatus_TemporaryRedirect = 307,
|
||||
HttpStatus_PermanentRedirect = 308,
|
||||
|
||||
/* 4xx - Client Error */
|
||||
HttpStatus_BadRequest = 400,
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user