From b93e3d233523f97f8a4da91016132b7ec94c52be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Jos=C3=A9?= Date: Fri, 4 Aug 2023 22:27:58 -0300 Subject: [PATCH 1/3] Add ability to set response wait time --- src/HttpClient.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/HttpClient.h b/src/HttpClient.h index 6a7aa1d..2ca2e31 100644 --- a/src/HttpClient.h +++ b/src/HttpClient.h @@ -384,6 +384,7 @@ class HttpClient : public Client // Stores the value of the current chunk length, if present int iChunkLength; uint32_t iHttpResponseTimeout; + uint32_t iHttpWaitForDataDelay; bool iConnectionClose; bool iSendDefaultRequestHeaders; String iHeaderLine; From 9b3987ca7ff6ba44a459e7401a12307711466a81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Jos=C3=A9?= Date: Fri, 4 Aug 2023 22:33:13 -0300 Subject: [PATCH 2/3] Add getter and setter functions --- src/HttpClient.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/HttpClient.h b/src/HttpClient.h index 2ca2e31..cf24d96 100644 --- a/src/HttpClient.h +++ b/src/HttpClient.h @@ -317,6 +317,8 @@ class HttpClient : public Client virtual operator bool() { return bool(iClient); }; virtual uint32_t httpResponseTimeout() { return iHttpResponseTimeout; }; virtual void setHttpResponseTimeout(uint32_t timeout) { iHttpResponseTimeout = timeout; }; + virtual uint32_t httpWaitForDataDelay() { return iHttpWaitForDataDelay; }; + virtual void setHttpWaitForDataDelay(uint32_t delay) { iHttpWaitForDataDelay = delay; }; protected: /** Reset internal state data back to the "just initialised" state */ From c490dde1f16875b988a45d21f9bb9678011061eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Jos=C3=A9?= Date: Fri, 4 Aug 2023 22:35:09 -0300 Subject: [PATCH 3/3] Replace delay constant by variable --- src/HttpClient.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/HttpClient.cpp b/src/HttpClient.cpp index 1c73464..5b07fd7 100644 --- a/src/HttpClient.cpp +++ b/src/HttpClient.cpp @@ -40,6 +40,7 @@ void HttpClient::resetState() iIsChunked = false; iChunkLength = 0; iHttpResponseTimeout = kHttpResponseTimeout; + iHttpWaitForDataDelay = kHttpWaitForDataDelay; } void HttpClient::stop() @@ -473,7 +474,7 @@ int HttpClient::responseStatusCode() { // We haven't got any data, so let's pause to allow some to // arrive - delay(kHttpWaitForDataDelay); + delay(iHttpWaitForDataDelay); } } if ( (c == '\n') && (iStatusCode < 200 && iStatusCode != 101) ) @@ -522,7 +523,7 @@ int HttpClient::skipResponseHeaders() { // We haven't got any data, so let's pause to allow some to // arrive - delay(kHttpWaitForDataDelay); + delay(iHttpWaitForDataDelay); } } if (endOfHeadersReached())