@@ -48,46 +48,46 @@ HTTPUpdate::~HTTPUpdate(void)
4848{
4949}
5050
51- HTTPUpdateResult HTTPUpdate::update (WiFiClient& client, const String& url, const String& currentVersion)
51+ HTTPUpdateResult HTTPUpdate::update (WiFiClient& client, const String& url, const String& currentVersion, HTTPUpdateRequestCB requestCB )
5252{
5353 HTTPClient http;
5454 if (!http.begin (client, url))
5555 {
5656 return HTTP_UPDATE_FAILED;
5757 }
58- return handleUpdate (http, currentVersion, false );
58+ return handleUpdate (http, currentVersion, false , requestCB );
5959}
6060
61- HTTPUpdateResult HTTPUpdate::updateSpiffs (HTTPClient& httpClient, const String& currentVersion)
61+ HTTPUpdateResult HTTPUpdate::updateSpiffs (HTTPClient& httpClient, const String& currentVersion, HTTPUpdateRequestCB requestCB )
6262{
63- return handleUpdate (httpClient, currentVersion, true );
63+ return handleUpdate (httpClient, currentVersion, true , requestCB );
6464}
6565
66- HTTPUpdateResult HTTPUpdate::updateSpiffs (WiFiClient& client, const String& url, const String& currentVersion)
66+ HTTPUpdateResult HTTPUpdate::updateSpiffs (WiFiClient& client, const String& url, const String& currentVersion, HTTPUpdateRequestCB requestCB )
6767{
6868 HTTPClient http;
6969 if (!http.begin (client, url))
7070 {
7171 return HTTP_UPDATE_FAILED;
7272 }
73- return handleUpdate (http, currentVersion, true );
73+ return handleUpdate (http, currentVersion, true , requestCB );
7474}
7575
7676HTTPUpdateResult HTTPUpdate::update (HTTPClient& httpClient,
77- const String& currentVersion)
77+ const String& currentVersion, HTTPUpdateRequestCB requestCB )
7878{
79- return handleUpdate (httpClient, currentVersion, false );
79+ return handleUpdate (httpClient, currentVersion, false , requestCB );
8080}
8181
8282HTTPUpdateResult HTTPUpdate::update (WiFiClient& client, const String& host, uint16_t port, const String& uri,
83- const String& currentVersion)
83+ const String& currentVersion, HTTPUpdateRequestCB requestCB )
8484{
8585 HTTPClient http;
8686 if (!http.begin (client, host, port, uri))
8787 {
8888 return HTTP_UPDATE_FAILED;
8989 }
90- return handleUpdate (http, currentVersion, false );
90+ return handleUpdate (http, currentVersion, false , requestCB );
9191}
9292
9393/* *
@@ -180,7 +180,7 @@ String getSketchSHA256() {
180180 * @param currentVersion const char *
181181 * @return HTTPUpdateResult
182182 */
183- HTTPUpdateResult HTTPUpdate::handleUpdate (HTTPClient& http, const String& currentVersion, bool spiffs)
183+ HTTPUpdateResult HTTPUpdate::handleUpdate (HTTPClient& http, const String& currentVersion, bool spiffs, HTTPUpdateRequestCB requestCB )
184184{
185185
186186 HTTPUpdateResult ret = HTTP_UPDATE_FAILED;
@@ -216,6 +216,9 @@ HTTPUpdateResult HTTPUpdate::handleUpdate(HTTPClient& http, const String& curren
216216 if (currentVersion && currentVersion[0 ] != 0x00 ) {
217217 http.addHeader (" x-ESP32-version" , currentVersion);
218218 }
219+ if (requestCB) {
220+ requestCB (&http);
221+ }
219222
220223 const char * headerkeys[] = { " x-MD5" };
221224 size_t headerkeyssize = sizeof (headerkeys) / sizeof (char *);
0 commit comments