Skip to content

Commit ce4d50b

Browse files
committed
Merge pull request amcewen#3 from johnmckerrell/master
Connected bug
2 parents fc72d82 + cc55357 commit ce4d50b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

HttpClient.cpp

Lines changed: 3 additions & 2 deletions
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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,10 @@ class HttpClient : public Client
370370
virtual int connect(IPAddress ip, uint16_t port) { return iClient->connect(ip, port); };
371371
virtual int connect(const char *host, uint16_t port) { return iClient->connect(host, port); };
372372
virtual void stop();
373-
virtual uint8_t connected() { iClient->connected(); };
373+
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)