esp_http_client: redirect_counter is never reset, will lead to redirection error if client is reused (IDFGH-12636) #13633
Labels
Awaiting Response
awaiting a response from the author
Resolution: NA
Issue resolution is unavailable
Status: Done
Issue is done internally
Type: Bug
bugs in IDF
Answers checklist.
IDF version.
v4.4.7
Espressif SoC revision.
ESP32
Operating System used.
Windows
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
PowerShell
Development Kit.
Custom Board
Power Supply used.
USB
What is the expected behavior?
I expect
esp_http_client_perform
to resetesp_http_client_handle_t.redirect_counter
so I can re-use the http_client handle multiple times.What is the actual behavior?
esp_http_client_handle_t.redirect_counter
is never reset.Steps to reproduce.
esp_http_client_init
esp_http_client_perform
multiple times, with the endpoint returning a 301 / 302 redirectesp_http_client_perform
fails.Debug Logs.
No response
More Information.
I'm not sure if this is intended. I want to avoid creating a new http client handle every time, so I'm reusing the client handle. The endpoint/server always stays the same. I just change the POSTed content using
esp_http_client_set_post_field
.Use case: POST to a server using
http
, but if the server returns a redirect to https, it should be followed. I guess the "ideal solution" would probably be to use the https URL in the first place, so change it on my code?The text was updated successfully, but these errors were encountered: