From 4eb25a73ff252499d737a1c577750c59c5094534 Mon Sep 17 00:00:00 2001 From: John McKerrell Date: Thu, 1 Nov 2012 16:23:12 +0000 Subject: [PATCH 1/2] Actually return the connected status :) --- HttpClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HttpClient.h b/HttpClient.h index 016d47a..55ab39b 100644 --- a/HttpClient.h +++ b/HttpClient.h @@ -370,7 +370,7 @@ public: virtual int connect(IPAddress ip, uint16_t port) { return iClient->connect(ip, port); }; virtual int connect(const char *host, uint16_t port) { return iClient->connect(host, port); }; virtual void stop(); - virtual uint8_t connected() { iClient->connected(); }; + virtual uint8_t connected() { return iClient->connected(); }; virtual operator bool() { return bool(iClient); }; protected: /** Reset internal state data back to the "just initialised" state From cc55357e77c93d2811ffc3f1687c98b5daf3f77d Mon Sep 17 00:00:00 2001 From: John McKerrell Date: Fri, 2 Nov 2012 19:25:05 +0000 Subject: [PATCH 2/2] Making http response timeout mutable --- HttpClient.cpp | 5 +++-- HttpClient.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HttpClient.cpp b/HttpClient.cpp index 4e5e10a..39a9ab7 100644 --- a/HttpClient.cpp +++ b/HttpClient.cpp @@ -48,6 +48,7 @@ void HttpClient::resetState() iContentLength = 0; iBodyLengthConsumed = 0; iContentLengthPtr = 0; + iHttpResponseTimeout = kHttpResponseTimeout; } void HttpClient::stop() @@ -311,7 +312,7 @@ int HttpClient::responseStatusCode() const char* statusPtr = statusPrefix; // Whilst we haven't timed out & haven't reached the end of the headers while ((c != '\n') && - ( (millis() - timeoutStart) < kHttpResponseTimeout )) + ( (millis() - timeoutStart) < iHttpResponseTimeout )) { if (available()) { @@ -401,7 +402,7 @@ int HttpClient::skipResponseHeaders() unsigned long timeoutStart = millis(); // Whilst we haven't timed out & haven't reached the end of the headers while ((!endOfHeadersReached()) && - ( (millis() - timeoutStart) < kHttpResponseTimeout )) + ( (millis() - timeoutStart) < iHttpResponseTimeout )) { if (available()) { diff --git a/HttpClient.h b/HttpClient.h index 55ab39b..e7cb624 100644 --- a/HttpClient.h +++ b/HttpClient.h @@ -372,6 +372,8 @@ public: virtual void stop(); virtual uint8_t connected() { return iClient->connected(); }; virtual operator bool() { return bool(iClient); }; + virtual uint32_t httpResponseTimeout() { return iHttpResponseTimeout; }; + virtual void setHttpResponseTimeout(uint32_t timeout) { iHttpResponseTimeout = timeout; }; protected: /** Reset internal state data back to the "just initialised" state */ @@ -434,6 +436,7 @@ protected: // Address of the proxy to use, if we're using one IPAddress iProxyAddress; uint16_t iProxyPort; + uint32_t iHttpResponseTimeout; }; #endif