From 409c80633d7c064130610d40101b3e3386b4b439 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Wed, 3 Feb 2016 10:32:18 -0800 Subject: [PATCH 1/5] Add support for stable branch of HTTP client library, fixes small whitespace nits. --- Firebase.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Firebase.cpp b/Firebase.cpp index 2f398c11..bfc69881 100644 --- a/Firebase.cpp +++ b/Firebase.cpp @@ -15,6 +15,13 @@ // #include "Firebase.h" +// Detect whether stable version of HTTP library is installed instead of +// master branch and patch in missing status and methods. +#ifndef HTTP_CODE_TEMPORARY_REDIRECT +#define HTTP_CODE_TEMPORARY_REDIRECT 307 +#define USE_STABLE_HTTPCLIENT_CORE +#endif + namespace { const char* kFirebaseFingerprint = "7A 54 06 9B DC 7A 25 B3 86 8D 66 53 48 2C 0B 96 42 C7 B3 0A"; const uint16_t kFirebasePort = 443; @@ -74,7 +81,7 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth, bool followRedirect = false; if (method == "STREAM") { method = "GET"; - http_->addHeader("Accept", "text/event-stream"); + http_->addHeader("Accept", "text/event-stream"); followRedirect = true; } @@ -82,7 +89,7 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth, const char* headers[] = {"Location"}; http_->collectHeaders(headers, 1); } - + int status = http_->sendRequest(method, (uint8_t*)data.c_str(), data.length()); // TODO: Add a max redirect check @@ -98,7 +105,11 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth, } if (status != 200) { +#ifdef USE_STABLE_HTTPCLIENT_CORE + error_ = FirebaseError(status, String(method) + " " + url + ": " + status); +#else error_ = FirebaseError(status, String(method) + " " + url + ": " + HTTPClient::errorToString(status)); +#endif } // if not streaming. @@ -112,7 +123,6 @@ FirebaseGet::FirebaseGet(const String& host, const String& auth, const String& path, HTTPClient* http) : FirebaseCall(host, auth, "GET", path, "", http) { - if (!error()) { // TODO: parse json json_ = response(); @@ -121,10 +131,9 @@ FirebaseGet::FirebaseGet(const String& host, const String& auth, // FirebaseSet FirebaseSet::FirebaseSet(const String& host, const String& auth, - const String& path, const String& value, - HTTPClient* http) + const String& path, const String& value, + HTTPClient* http) : FirebaseCall(host, auth, "PUT", path, value, http) { - if (!error()) { // TODO: parse json json_ = response(); From 0f6ce71038da05fe4cfae0f55ce931a45feab0d6 Mon Sep 17 00:00:00 2001 From: Gus Class Date: Thu, 4 Feb 2016 14:19:08 -0800 Subject: [PATCH 2/5] Feedback from review --- Firebase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firebase.cpp b/Firebase.cpp index bfc69881..ccca72cd 100644 --- a/Firebase.cpp +++ b/Firebase.cpp @@ -19,7 +19,7 @@ // master branch and patch in missing status and methods. #ifndef HTTP_CODE_TEMPORARY_REDIRECT #define HTTP_CODE_TEMPORARY_REDIRECT 307 -#define USE_STABLE_HTTPCLIENT_CORE +#define USE_ARDUINO_CORE_2_0_0 #endif namespace { @@ -105,7 +105,7 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth, } if (status != 200) { -#ifdef USE_STABLE_HTTPCLIENT_CORE +#ifdef USE_ARDUINO_CORE_2_0_0 error_ = FirebaseError(status, String(method) + " " + url + ": " + status); #else error_ = FirebaseError(status, String(method) + " " + url + ": " + HTTPClient::errorToString(status)); From d3a4c1b31ff1835cdd3bccc6703e218eeb5b224b Mon Sep 17 00:00:00 2001 From: Gus Class Date: Fri, 5 Feb 2016 12:11:01 -0800 Subject: [PATCH 3/5] Adds link to stable installer via boards manager --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7e88f50c..c8992e9c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This sample shows how to call [Firebase](https://www.firebase.com/) from the [ES - 1 [ESP8266 Arduino board](https://www.adafruit.com/products/2821). - [Arduino 1.6.x](https://www.arduino.cc/en/Main/Software) -- ESP8266 Arduino board definition [(master branch)](https://github.com/esp8266/Arduino#using-git-version-) +- ESP8266 Arduino board definition [(master branch)](https://github.com/esp8266/Arduino#using-git-version-) or [install stable with Boards Manager](https://github.com/esp8266/Arduino#installing-with-boards-manager) ## Setup From 7d38e14759b0bc7b428c2f841add7d19cb24c950 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Mon, 8 Feb 2016 10:57:52 -0800 Subject: [PATCH 4/5] README: update arduino board definition link --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c8992e9c..7228979c 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ This sample shows how to call [Firebase](https://www.firebase.com/) from the [ES ## Requirements - 1 [ESP8266 Arduino board](https://www.adafruit.com/products/2821). -- [Arduino 1.6.x](https://www.arduino.cc/en/Main/Software) -- ESP8266 Arduino board definition [(master branch)](https://github.com/esp8266/Arduino#using-git-version-) or [install stable with Boards Manager](https://github.com/esp8266/Arduino#installing-with-boards-manager) +- [Arduino 1.6.7](https://www.arduino.cc/en/Main/Software) +- [ESP8266 Arduino board definition](https://github.com/esp8266/Arduino#installing-with-boards-manager) ## Setup From b8ae21c0454bd238009238c66d89febd6732a542 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Mon, 8 Feb 2016 11:02:27 -0800 Subject: [PATCH 5/5] Firebase: update arduino core define --- Firebase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firebase.cpp b/Firebase.cpp index ccca72cd..154a72f3 100644 --- a/Firebase.cpp +++ b/Firebase.cpp @@ -19,7 +19,7 @@ // master branch and patch in missing status and methods. #ifndef HTTP_CODE_TEMPORARY_REDIRECT #define HTTP_CODE_TEMPORARY_REDIRECT 307 -#define USE_ARDUINO_CORE_2_0_0 +#define USE_ESP_ARDUINO_CORE_2_0_0 #endif namespace { @@ -105,7 +105,7 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth, } if (status != 200) { -#ifdef USE_ARDUINO_CORE_2_0_0 +#ifdef USE_ESP_ARDUINO_CORE_2_0_0 error_ = FirebaseError(status, String(method) + " " + url + ": " + status); #else error_ = FirebaseError(status, String(method) + " " + url + ": " + HTTPClient::errorToString(status));