1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

add http client configurable timeout usefull when download is slow on server side (#4705)

* add http client configurable timeout usefull when download is slow from server side

* member init outside constructor body.

* removed this.
This commit is contained in:
Marian Craciunescu 2018-05-04 17:18:15 +03:00 committed by Develo
parent 76a14b1f63
commit bd87970aae
3 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,5 @@
name=ESP8266httpUpdate
version=1.1
version=1.2
author=Markus Sattler
maintainer=Markus Sattler
sentence=Http Update for ESP8266

View File

@ -30,6 +30,12 @@ extern "C" uint32_t _SPIFFS_start;
extern "C" uint32_t _SPIFFS_end;
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
: _httpClientTimeout(8000)
{
}
ESP8266HTTPUpdate::ESP8266HTTPUpdate(int httpClientTimeout)
: _httpClientTimeout(httpClientTimeout)
{
}
@ -170,7 +176,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
// use HTTP/1.0 for update since the update handler not support any transfer Encoding
http.useHTTP10(true);
http.setTimeout(8000);
http.setTimeout(_httpClientTimeout);
http.setUserAgent(F("ESP8266-http-Update"));
http.addHeader(F("x-ESP8266-STA-MAC"), WiFi.macAddress());
http.addHeader(F("x-ESP8266-AP-MAC"), WiFi.softAPmacAddress());

View File

@ -64,6 +64,7 @@ class ESP8266HTTPUpdate
{
public:
ESP8266HTTPUpdate(void);
ESP8266HTTPUpdate(int httpClientTimeout);
~ESP8266HTTPUpdate(void);
void rebootOnUpdate(bool reboot)
@ -103,6 +104,8 @@ protected:
int _lastError;
bool _rebootOnUpdate = true;
private:
int _httpClientTimeout;
};
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_HTTPUPDATE)