mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
esp_http_client: Skip check for redirection counter if status code is success.
Set disable_auto_redirect in esp_http_client example to validate this condition in CI
This commit is contained in:
@ -650,6 +650,9 @@ esp_err_t esp_http_client_set_redirection(esp_http_client_handle_t client)
|
|||||||
|
|
||||||
static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
|
static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
|
||||||
{
|
{
|
||||||
|
if (client->response->status_code >= HttpStatus_Ok && client->response->status_code < HttpStatus_MultipleChoices) {
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
if (client->redirect_counter >= client->max_redirection_count || client->disable_auto_redirect) {
|
if (client->redirect_counter >= client->max_redirection_count || client->disable_auto_redirect) {
|
||||||
ESP_LOGE(TAG, "Error, reach max_redirection_count count=%d", client->redirect_counter);
|
ESP_LOGE(TAG, "Error, reach max_redirection_count count=%d", client->redirect_counter);
|
||||||
return ESP_ERR_HTTP_MAX_REDIRECT;
|
return ESP_ERR_HTTP_MAX_REDIRECT;
|
||||||
|
@ -128,7 +128,11 @@ typedef struct {
|
|||||||
* Enum for the HTTP status codes.
|
* Enum for the HTTP status codes.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
/* 2xx - Success */
|
||||||
|
HttpStatus_Ok = 200,
|
||||||
|
|
||||||
/* 3xx - Redirection */
|
/* 3xx - Redirection */
|
||||||
|
HttpStatus_MultipleChoices = 300,
|
||||||
HttpStatus_MovedPermanently = 301,
|
HttpStatus_MovedPermanently = 301,
|
||||||
HttpStatus_Found = 302,
|
HttpStatus_Found = 302,
|
||||||
|
|
||||||
|
@ -81,6 +81,7 @@ static void http_rest_with_url()
|
|||||||
esp_http_client_config_t config = {
|
esp_http_client_config_t config = {
|
||||||
.url = "http://httpbin.org/get",
|
.url = "http://httpbin.org/get",
|
||||||
.event_handler = _http_event_handler,
|
.event_handler = _http_event_handler,
|
||||||
|
.disable_auto_redirect = true,
|
||||||
};
|
};
|
||||||
esp_http_client_handle_t client = esp_http_client_init(&config);
|
esp_http_client_handle_t client = esp_http_client_init(&config);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user