Skip to content

Commit cc55357

Browse files
committed
Making http response timeout mutable
1 parent 4eb25a7 commit cc55357

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

HttpClient.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ void HttpClient::resetState()
4848
iContentLength = 0;
4949
iBodyLengthConsumed = 0;
5050
iContentLengthPtr = 0;
51+
iHttpResponseTimeout = kHttpResponseTimeout;
5152
}
5253

5354
void HttpClient::stop()
@@ -311,7 +312,7 @@ int HttpClient::responseStatusCode()
311312
const char* statusPtr = statusPrefix;
312313
// Whilst we haven't timed out & haven't reached the end of the headers
313314
while ((c != '\n') &&
314-
( (millis() - timeoutStart) < kHttpResponseTimeout ))
315+
( (millis() - timeoutStart) < iHttpResponseTimeout ))
315316
{
316317
if (available())
317318
{
@@ -401,7 +402,7 @@ int HttpClient::skipResponseHeaders()
401402
unsigned long timeoutStart = millis();
402403
// Whilst we haven't timed out & haven't reached the end of the headers
403404
while ((!endOfHeadersReached()) &&
404-
( (millis() - timeoutStart) < kHttpResponseTimeout ))
405+
( (millis() - timeoutStart) < iHttpResponseTimeout ))
405406
{
406407
if (available())
407408
{

HttpClient.h

+3
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ class HttpClient : public Client
372372
virtual void stop();
373373
virtual uint8_t connected() { return iClient->connected(); };
374374
virtual operator bool() { return bool(iClient); };
375+
virtual uint32_t httpResponseTimeout() { return iHttpResponseTimeout; };
376+
virtual void setHttpResponseTimeout(uint32_t timeout) { iHttpResponseTimeout = timeout; };
375377
protected:
376378
/** Reset internal state data back to the "just initialised" state
377379
*/
@@ -434,6 +436,7 @@ class HttpClient : public Client
434436
// Address of the proxy to use, if we're using one
435437
IPAddress iProxyAddress;
436438
uint16_t iProxyPort;
439+
uint32_t iHttpResponseTimeout;
437440
};
438441

439442
#endif

0 commit comments

Comments
 (0)