From df2a51836193711cf935123211136da1aee1571d Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Wed, 6 Apr 2016 12:19:19 -0400 Subject: [PATCH 1/3] Make sure timeout is always initialized in constructors, reduce constructor code duplication --- RestClient.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/RestClient.cpp b/RestClient.cpp index 33cdc0d..4573f76 100644 --- a/RestClient.cpp +++ b/RestClient.cpp @@ -11,14 +11,8 @@ #endif -RestClient::RestClient(Client& netClient, const char* _host) { - host = _host; - port = 80; - num_headers = 0; - contentType = "x-www-form-urlencoded"; // default - this->client = &netClient; - this->responseBody = ""; - this->timeout = 1000; // default. TODO: add a setter function +RestClient::RestClient(Client& netClient, const char* _host) : + RestClient(netClient, _host, 80) { } RestClient::RestClient(Client& netClient, const char* _host, int _port) { @@ -27,6 +21,8 @@ RestClient::RestClient(Client& netClient, const char* _host, int _port) { num_headers = 0; contentType = "application/x-www-form-urlencoded"; // default this->client = &netClient; + this->responseBody = ""; + this->timeout = 1000; // default. TODO: add a setter function } // GET path From 75d6b5f2e2b99a2c1b73d82e1b8af45c9f1fb523 Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Wed, 6 Apr 2016 12:19:41 -0400 Subject: [PATCH 2/3] Bump timeout to 10 seconds --- RestClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RestClient.cpp b/RestClient.cpp index 4573f76..6e96f6d 100644 --- a/RestClient.cpp +++ b/RestClient.cpp @@ -22,7 +22,7 @@ RestClient::RestClient(Client& netClient, const char* _host, int _port) { contentType = "application/x-www-form-urlencoded"; // default this->client = &netClient; this->responseBody = ""; - this->timeout = 1000; // default. TODO: add a setter function + this->timeout = 10000; // default. TODO: add a setter function } // GET path From a82e2dc1628c386c6a7a17b243b9fe58aa35ec49 Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Wed, 6 Apr 2016 12:21:14 -0400 Subject: [PATCH 3/3] Remove unnecessary delay --- RestClient.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/RestClient.cpp b/RestClient.cpp index 6e96f6d..a1dcf6e 100644 --- a/RestClient.cpp +++ b/RestClient.cpp @@ -97,10 +97,6 @@ int RestClient::request(const char* method, String path, String body){ client->print(requestString); HTTP_DEBUG_PRINT(requestString); - // make sure you've sent all bytes. Ugly hack. - // TODO: check output buffer instead? - delay(50); - HTTP_DEBUG_PRINT("HTTP: call getResponse\n"); int statusCode = getResponse(); HTTP_DEBUG_PRINT("HTTP: return getResponse\n");