@@ -28,11 +28,17 @@ Firebase& Firebase::auth(const String& auth) {
28
28
}
29
29
30
30
String Firebase::get (const String& path) {
31
- return sendRequest (" GET" , path);
31
+ sendRequest (" GET" , path);
32
+ return readBody ();
32
33
}
33
34
34
35
String Firebase::push (const String& path, const String& value) {
35
- return sendRequest (" POST" , path, value);
36
+ sendRequest (" POST" , path, value);
37
+ return readBody ();
38
+ }
39
+
40
+ void Firebase::remove (const String& path) {
41
+ sendRequest (" DELETE" , path);
36
42
}
37
43
38
44
Firebase& Firebase::stream (const String& path) {
@@ -74,15 +80,20 @@ String Firebase::makeURL(const String& path) {
74
80
return url;
75
81
}
76
82
77
- String Firebase::sendRequest (const char * method, const String& path, const String& value) {
78
- _error.reset ();
83
+ void Firebase::sendRequest (const char * method, const String& path, const String& value) {
79
84
String url = makeURL (path);
80
85
_http.begin (_host.c_str (), firebasePort, url.c_str (), true , firebaseFingerprint);
81
- int statusCode = _http.sendRequest (method, (uint8_t *)value.c_str (), value.length ());
86
+ int statusCode = _http.sendRequest (method, (uint8_t *)value.c_str (), value.length ());
87
+ _error.reset ();
82
88
if (statusCode < 0 ) {
83
89
_error.set (statusCode,
84
- String (method) + " " + url + " : "
85
- + HTTPClient::errorToString (statusCode));
90
+ String (method) + " " + url + " : "
91
+ + HTTPClient::errorToString (statusCode));
92
+ }
93
+ }
94
+
95
+ String Firebase::readBody () {
96
+ if (_error.code () != 0 ) {
86
97
return " " ;
87
98
}
88
99
// no _http.end() because of connection reuse.
0 commit comments