fix: esp_http_client fix behaviour when disable_auto_redirect is enabled

This commit is contained in:
harshal.patil 2022-10-26 14:47:21 +05:30
parent 0954c5e5d0
commit 5feb4696be
2 changed files with 3 additions and 1 deletions

View File

@ -851,8 +851,9 @@ static esp_err_t esp_http_check_response(esp_http_client_handle_t client)
case HttpStatus_PermanentRedirect:
if (client->disable_auto_redirect) {
http_dispatch_event(client, HTTP_EVENT_REDIRECT, NULL, 0);
} else {
ESP_ERROR_CHECK(esp_http_client_set_redirection(client));
}
esp_http_client_set_redirection(client);
client->redirect_counter ++;
client->process_again = 1;
break;

View File

@ -115,6 +115,7 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
ESP_LOGD(TAG, "HTTP_EVENT_REDIRECT");
esp_http_client_set_header(evt->client, "From", "user@example.com");
esp_http_client_set_header(evt->client, "Accept", "text/html");
esp_http_client_set_redirection(evt->client);
break;
}
return ESP_OK;