8000 Update HTTPUpdate.cpp (#4942) · eried/arduino-esp32@63c51d5 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 63c51d5

Browse files
authored
Update HTTPUpdate.cpp (espressif#4942)
This is a mirror of a change in esp8266 needed to update with a url that redirects.
1 parent 5b84527 commit 63c51d5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

libraries/HTTPUpdate/src/HTTPUpdate.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
HTTPUpdate::HTTPUpdate(void)
3636
: _httpClientTimeout(8000), _ledPin(-1)
3737
{
38+
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
3839
}
3940

4041
HTTPUpdate::HTTPUpdate(int httpClientTimeout)
4142
: _httpClientTimeout(httpClientTimeout), _ledPin(-1)
4243
{
44+
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
4345
}
4446

4547
HTTPUpdate::~HTTPUpdate(void)
@@ -175,6 +177,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
175177
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
176178
http.useHTTP10(true);
177179
http.setTimeout(_httpClientTimeout);
180+
http.setFollowRedirects(_followRedirects);
178181
http.setUserAgent("ESP32-http-Update");
179182
http.addHeader("Cache-Control", "no-cache");
180183
http.addHeader("x-ESP32-STA-MAC", WiFi.macAddress());

libraries/HTTPUpdate/src/HTTPUpdate.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ class HTTPUpdate
6363
{
6464
_rebootOnUpdate = reboot;
6565
}
66+
67+
/**
68+
* set redirect follow mode. See `followRedirects_t` enum for avaliable modes.
69+
* @param follow
70+
*/
71+
void setFollowRedirects(followRedirects_t follow)
72+
{
73+
_followRedirects = follow;
74+
}
6675

6776
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
6877
{
@@ -89,6 +98,7 @@ class HTTPUpdate
8998
bool _rebootOnUpdate = true;
9099
private:
91100
int _httpClientTimeout;
101+
followRedirects_t _followRedirects;
92102

93103
int _ledPin;
94104
uint8_t _ledOn;

0 commit comments

Comments
 (0)
0