Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp_http_client: redirect_counter is never reset, will lead to redirection error if client is reused (IDFGH-12636) #13633

Closed
3 tasks done
hurricanefrog opened this issue Apr 17, 2024 · 1 comment
Assignees
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

Comments

@hurricanefrog
Copy link

hurricanefrog commented Apr 17, 2024

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

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 reset esp_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.

  1. Create an http client using esp_http_client_init
  2. Set connection info / URL.
  3. Call esp_http_client_perform multiple times, with the endpoint returning a 301 / 302 redirect
  4. After 10 times, the error will appear. esp_http_client_perform fails.
E (88888) HTTP_CLIENT: Error, reach max_redirection_count count=10
E (88889) HTTP_CLIENT: Error response

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?

@hurricanefrog hurricanefrog added the Type: Bug bugs in IDF label Apr 17, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 17, 2024
@github-actions github-actions bot changed the title esp_http_client: redirect_counter is never reset, will lead to redirection error if client is reused esp_http_client: redirect_counter is never reset, will lead to redirection error if client is reused (IDFGH-12636) Apr 17, 2024
@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Apr 22, 2024
@hmalpani
Copy link
Collaborator

hmalpani commented May 3, 2024

Hello @hurricanefrog
Thanks for reporting the issue. I have created a patch to fix this issue. Can you please check and let me know if the patch helps you in resolving the issue?
Thanks!
IDFGH-12636.txt

@espressif-bot espressif-bot added Awaiting Response awaiting a response from the author Status: Done Issue is done internally Resolution: NA Issue resolution is unavailable and removed Status: In Progress Work is in progress labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants