Skip to content

Commit d3f16b3

Browse files
authored
Allow manually setting MD5 checksum for HTTP update (#8204)
1 parent 058ce7c commit d3f16b3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,14 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
211211
DEBUG_HTTP_UPDATE("[httpUpdate] - code: %d\n", code);
212212
DEBUG_HTTP_UPDATE("[httpUpdate] - len: %d\n", len);
213213

214-
if(http.hasHeader("x-MD5")) {
215-
DEBUG_HTTP_UPDATE("[httpUpdate] - MD5: %s\n", http.header("x-MD5").c_str());
214+
String md5;
215+
if (_md5Sum.length()) {
216+
md5 = _md5Sum;
217+
} else if(http.hasHeader("x-MD5")) {
218+
md5 = http.header("x-MD5");
219+
}
220+
if(md5.length()) {
221+
DEBUG_HTTP_UPDATE("[httpUpdate] - MD5: %s\n", md5.c_str());
216222
}
217223

218224
DEBUG_HTTP_UPDATE("[httpUpdate] ESP8266 info:\n");
@@ -298,7 +304,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::handleUpdate(HTTPClient& http, const String&
298304
}
299305
}
300306
}
301-
if(runUpdate(*tcp, len, http.header("x-MD5"), command)) {
307+
if(runUpdate(*tcp, len, md5, command)) {
302308
ret = HTTP_UPDATE_OK;
303309
DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n");
304310
http.end();

libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ class ESP8266HTTPUpdate
108108
_ledOn = ledOn;
109109
}
110110

111+
void setMD5sum(const String &md5Sum)
112+
{
113+
_md5Sum = md5Sum;
114+
}
115+
111116
void setAuthorization(const String& user, const String& password);
112117
void setAuthorization(const String& auth);
113118

@@ -142,7 +147,7 @@ class ESP8266HTTPUpdate
142147
String _user;
143148
String _password;
144149
String _auth;
145-
150+
String _md5Sum;
146151
private:
147152
int _httpClientTimeout;
148153
followRedirects_t _followRedirects = HTTPC_DISABLE_FOLLOW_REDIRECTS;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy