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

Allow manually setting MD5 checksum for HTTP update (#8204)

This commit is contained in:
Vlasta Hajek 2021-09-04 19:34:00 +02:00 committed by GitHub
parent 058ce7c08e
commit d3f16b3177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -211,8 +211,14 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
DEBUG_HTTP_UPDATE("[httpUpdate] - code: %d\n", code);
DEBUG_HTTP_UPDATE("[httpUpdate] - len: %d\n", len);
if(http.hasHeader("x-MD5")) {
DEBUG_HTTP_UPDATE("[httpUpdate] - MD5: %s\n", http.header("x-MD5").c_str());
String md5;
if (_md5Sum.length()) {
md5 = _md5Sum;
} else if(http.hasHeader("x-MD5")) {
md5 = http.header("x-MD5");
}
if(md5.length()) {
DEBUG_HTTP_UPDATE("[httpUpdate] - MD5: %s\n", md5.c_str());
}
DEBUG_HTTP_UPDATE("[httpUpdate] ESP8266 info:\n");
@ -298,7 +304,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
}
}
}
if(runUpdate(*tcp, len, http.header("x-MD5"), command)) {
if(runUpdate(*tcp, len, md5, command)) {
ret = HTTP_UPDATE_OK;
DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n");
http.end();

View File

@ -108,6 +108,11 @@ public:
_ledOn = ledOn;
}
void setMD5sum(const String &md5Sum)
{
_md5Sum = md5Sum;
}
void setAuthorization(const String& user, const String& password);
void setAuthorization(const String& auth);
@ -142,7 +147,7 @@ protected:
String _user;
String _password;
String _auth;
String _md5Sum;
private:
int _httpClientTimeout;
followRedirects_t _followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;