Skip to content

Commit

Permalink
Merge pull request #158 from AnCaPepe/AnCaPepe-custom-wait-delay
Browse files Browse the repository at this point in the history
Add ability to set response wait time
  • Loading branch information
andreagilardoni authored Mar 21, 2024
2 parents 2143747 + c490dde commit 5c5fafb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void HttpClient::resetState()
iIsChunked = false;
iChunkLength = 0;
iHttpResponseTimeout = kHttpResponseTimeout;
iHttpWaitForDataDelay = kHttpWaitForDataDelay;
}

void HttpClient::stop()
Expand Down Expand Up @@ -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) )
Expand Down Expand Up @@ -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())
Expand Down
3 changes: 3 additions & 0 deletions src/HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -384,6 +386,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;
Expand Down

0 comments on commit 5c5fafb

Please sign in to comment.