Update HTTPUpdate.cpp (#4942)
This is a mirror of a change in esp8266 needed to update with a url that redirects.
This commit is contained in:
parent
5b845272ed
commit
63c51d51fb
@ -35,11 +35,13 @@
|
|||||||
HTTPUpdate::HTTPUpdate(void)
|
HTTPUpdate::HTTPUpdate(void)
|
||||||
: _httpClientTimeout(8000), _ledPin(-1)
|
: _httpClientTimeout(8000), _ledPin(-1)
|
||||||
{
|
{
|
||||||
|
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPUpdate::HTTPUpdate(int httpClientTimeout)
|
HTTPUpdate::HTTPUpdate(int httpClientTimeout)
|
||||||
: _httpClientTimeout(httpClientTimeout), _ledPin(-1)
|
: _httpClientTimeout(httpClientTimeout), _ledPin(-1)
|
||||||
{
|
{
|
||||||
|
_followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
HTTPUpdate::~HTTPUpdate(void)
|
HTTPUpdate::~HTTPUpdate(void)
|
||||||
@ -175,6 +177,7 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
|
|||||||
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
|
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
|
||||||
http.useHTTP10(true);
|
http.useHTTP10(true);
|
||||||
http.setTimeout(_httpClientTimeout);
|
http.setTimeout(_httpClientTimeout);
|
||||||
|
http.setFollowRedirects(_followRedirects);
|
||||||
http.setUserAgent("ESP32-http-Update");
|
http.setUserAgent("ESP32-http-Update");
|
||||||
http.addHeader("Cache-Control", "no-cache");
|
http.addHeader("Cache-Control", "no-cache");
|
||||||
http.addHeader("x-ESP32-STA-MAC", WiFi.macAddress());
|
http.addHeader("x-ESP32-STA-MAC", WiFi.macAddress());
|
||||||
|
@ -64,6 +64,15 @@ public:
|
|||||||
_rebootOnUpdate = reboot;
|
_rebootOnUpdate = reboot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set redirect follow mode. See `followRedirects_t` enum for avaliable modes.
|
||||||
|
* @param follow
|
||||||
|
*/
|
||||||
|
void setFollowRedirects(followRedirects_t follow)
|
||||||
|
{
|
||||||
|
_followRedirects = follow;
|
||||||
|
}
|
||||||
|
|
||||||
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
|
void setLedPin(int ledPin = -1, uint8_t ledOn = HIGH)
|
||||||
{
|
{
|
||||||
_ledPin = ledPin;
|
_ledPin = ledPin;
|
||||||
@ -89,6 +98,7 @@ protected:
|
|||||||
bool _rebootOnUpdate = true;
|
bool _rebootOnUpdate = true;
|
||||||
private:
|
private:
|
||||||
int _httpClientTimeout;
|
int _httpClientTimeout;
|
||||||
|
followRedirects_t _followRedirects;
|
||||||
|
|
||||||
int _ledPin;
|
int _ledPin;
|
||||||
uint8_t _ledOn;
|
uint8_t _ledOn;
|
||||||
|
Loading…
Reference in New Issue
Block a user