From 93bcf5f2502dbc448ddb93cdcfb789ce14e574b9 Mon Sep 17 00:00:00 2001 From: Mohammed Noureldin Date: Thu, 18 Mar 2021 12:12:57 +0100 Subject: [PATCH] Allow passing custom HTTPClient to HTTPUpdate (#4959) This enables customizing HTTP headers which adds some extra flexibility. This does not break anything of course because this change introduces a new constructor with a new additional HTTPClient argument for HTTPUpdate class. --- libraries/HTTPUpdate/src/HTTPUpdate.cpp | 11 +++++++++++ libraries/HTTPUpdate/src/HTTPUpdate.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/libraries/HTTPUpdate/src/HTTPUpdate.cpp b/libraries/HTTPUpdate/src/HTTPUpdate.cpp index c7cb8f8db..d5c65f200 100644 --- a/libraries/HTTPUpdate/src/HTTPUpdate.cpp +++ b/libraries/HTTPUpdate/src/HTTPUpdate.cpp @@ -58,6 +58,11 @@ HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& url, const return handleUpdate(http, currentVersion, false); } +HTTPUpdateResult HTTPUpdate::updateSpiffs(HTTPClient& httpClient, const String& currentVersion) +{ + return handleUpdate(httpClient, currentVersion, true); +} + HTTPUpdateResult HTTPUpdate::updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion) { HTTPClient http; @@ -68,6 +73,12 @@ HTTPUpdateResult HTTPUpdate::updateSpiffs(WiFiClient& client, const String& url, return handleUpdate(http, currentVersion, true); } +HTTPUpdateResult HTTPUpdate::update(HTTPClient& httpClient, + const String& currentVersion) +{ + return handleUpdate(httpClient, currentVersion, false); +} + HTTPUpdateResult HTTPUpdate::update(WiFiClient& client, const String& host, uint16_t port, const String& uri, const String& currentVersion) { diff --git a/libraries/HTTPUpdate/src/HTTPUpdate.h b/libraries/HTTPUpdate/src/HTTPUpdate.h index 7b2d39098..af404e718 100644 --- a/libraries/HTTPUpdate/src/HTTPUpdate.h +++ b/libraries/HTTPUpdate/src/HTTPUpdate.h @@ -86,6 +86,10 @@ public: t_httpUpdate_return updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion = ""); + t_httpUpdate_return update(HTTPClient& httpClient, + const String& currentVersion = ""); + + t_httpUpdate_return updateSpiffs(HTTPClient &httpClient, const String ¤tVersion = ""); int getLastError(void); String getLastErrorString(void); -- GitLab