@@ -29,17 +29,16 @@ Firebase& Firebase::auth(const String& auth) {
29
29
30
30
String Firebase::get (const String& path) {
31
31
sendRequest (" GET" , path);
32
- return getBody ();
32
+ return readBody ();
33
33
}
34
34
35
35
String Firebase::push (const String& path, const String& value) {
36
36
sendRequest (" POST" , path, value);
37
- return getBody ();
37
+ return readBody ();
38
38
}
39
39
40
- bool Firebase::remove (const String& path) {
41
- int status = sendRequest (" DELETE" , path);
42
- return status == HTTP_CODE_OK;
40
+ void Firebase::remove (const String& path) {
41
+ sendRequest (" DELETE" , path);
43
42
}
44
43
45
44
Firebase& Firebase::stream (const String& path) {
@@ -81,31 +80,26 @@ String Firebase::makeURL(const String& path) {
81
80
return url;
82
81
}
83
82
84
- int Firebase::sendRequest (const char * method, const String& path, const String& value) {
83
+ void Firebase::sendRequest (const char * method, const String& path, const String& value) {
85
84
String url = makeURL (path);
86
85
_http.begin (_host.c_str (), firebasePort, url.c_str (), true , firebaseFingerprint);
87
86
int statusCode = _http.sendRequest (method, (uint8_t *)value.c_str (), value.length ());
88
- checkResponse (method, url, statusCode);
89
- return statusCode;
87
+ _error.reset ();
88
+ if (statusCode < 0 ) {
89
+ _error.set (statusCode,
90
+ String (method) + " " + url + " : "
91
+ + HTTPClient::errorToString (statusCode));
92
+ }
90
93
}
91
94
92
- String Firebase::getBody () {
95
+ String Firebase::readBody () {
93
96
if (_error.code () != 0 ) {
94
97
return " " ;
95
98
}
96
99
// no _http.end() because of connection reuse.
97
100
return _http.getString ();
98
101
}
99
102
100
- void Firebase::checkResponse (const char * method, const String& url, int statusCode) {
101
- _error.reset ();
102
- if (statusCode < 0 ) {
103
- _error.set (statusCode,
104
- String (method) + " " + url + " : "
105
- + HTTPClient::errorToString (statusCode));
106
- }
107
- }
108
-
109
103
bool Firebase::connected () {
110
104
return _http.connected ();
111
105
}
0 commit comments