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

Configurable HTTP redirect following #3100

Merged
merged 7 commits into from Jan 25, 2022

Conversation

guillempages
Copy link
Contributor

@guillempages guillempages commented Jan 23, 2022

What does this implement/fix?

Add the possibility to configuring "follow redirects" for HTTP requests.

In my setup, I am doing a HTTP request to an apache virtual host and it sends a redirect response (HTTP code: 300).
In order for the request to actually succeed, the "FOLLOW_REDIRECTS" option needs to be set to the HTTPClient instance.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Related issue or feature (if applicable): fixes
No issue (that I am aware of). If needed I can create one.

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#1839

Test Environment

  • ESP32 (inkplate 10)
  • ESP32 IDF
  • ESP8266

Example entry for config.yaml:

http_request:
  follow_redirects: true
  redirect_limit: 15

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

Sometimes the server is behind a proxy that redirects to the final server.
Add the possibility of automatically following redirects if desired.
esphome/components/http_request/__init__.py Outdated Show resolved Hide resolved
esphome/components/http_request/http_request.h Outdated Show resolved Hide resolved
guillempages added a commit to guillempages/esphome-docs that referenced this pull request Jan 23, 2022
Update documentation according to PR esphome/esphome#3100
Copy link
Member

@oxan oxan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor nits, looks good otherwise.

esphome/components/http_request/http_request.cpp Outdated Show resolved Hide resolved
esphome/components/http_request/http_request.cpp Outdated Show resolved Hide resolved
guillempages added a commit to guillempages/esphome-docs that referenced this pull request Jan 25, 2022
Update documentation according to PR esphome/esphome#3100
guillempages and others added 3 commits January 25, 2022 09:14
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
Co-authored-by: Oxan van Leeuwen <oxan@oxanvanleeuwen.nl>
@oxan oxan merged commit 7a0827e into esphome:dev Jan 25, 2022
@oxan oxan changed the title Http follow requests Configurable HTTP redirect following Jan 25, 2022
@oxan
Copy link
Member

oxan commented Jan 25, 2022

Thanks!

@guillempages guillempages deleted the http_follow_requests branch January 26, 2022 07:50
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants