@@ -58,6 +58,40 @@ FirebaseEventStream Firebase::stream(const String& path) {
58
58
return FirebaseEventStream (host_, auth_, path);
59
59
}
60
60
61
+ /* FirebaseCall*/
62
+
63
+ FirebaseCall::FirebaseCall (const String& host,const String& auth,
64
+ const char * method,const String& path,const String& value,
65
+ HTTPClient* http) : http_(http) {
66
+ const String url =makeUrl (path, auth);
67
+ http_->begin (host.c_str (),kFirebasePort , url.c_str (),true ,kFirebaseFingerprint );
68
+ status_ = http_->sendRequest (method, (uint8_t *)value.c_str (), value.length ());
69
+ if (isError ()) {
70
+ error_message_ =String (method) +" " + url +" :" +HTTPClient::errorToString (status_);
71
+ }
72
+ }
73
+
74
+ FirebaseCall::FirebaseCall (const String& host,const String& auth,
75
+ const char * method,const String& path,
76
+ HTTPClient* http) : FirebaseCall(host, auth, method, path," " , http) {
77
+ }
78
+
79
+ bool FirebaseCall::isOk ()const {
80
+ return status_ == HTTP_CODE_OK;
81
+ }
82
+
83
+ bool FirebaseCall::isError ()const {
84
+ return status_ <0 ;
85
+ }
86
+
87
+ StringFirebaseCall::errorMessage ()const {
88
+ return error_message_;
89
+ }
90
+
91
+ StringFirebaseCall::rawResponse () {
92
+ return http_->getString ();
93
+ }
94
+
61
95
/* FirebaseEventStream*/
62
96
63
97
FirebaseEventStream::FirebaseEventStream (const String& host,const String& auth,
@@ -81,6 +115,11 @@ FirebaseEventStream::FirebaseEventStream(const String& host, const String& auth,
81
115
http_.begin (location,kFirebaseFingerprint );
82
116
status_ = http_.sendRequest (" GET" , (uint8_t *)NULL ,0 );
83
117
}
118
+
119
+ if (status_ !=200 ) {
120
+ error_message_ =" stream" + location +" :"
121
+ +HTTPClient::errorToString (status_);
122
+ }
84
123
}
85
124
86
125
bool FirebaseEventStream::connected () {
@@ -115,35 +154,4 @@ String FirebaseEventStream::errorMessage() const {
115
154
return error_message_;
116
155
}
117
156
118
- /* FirebaseCall*/
119
- FirebaseCall::FirebaseCall (const String& host,const String& auth,
120
- const char * method,const String& path,const String& value,
121
- HTTPClient* http) : http_(http) {
122
- const String url =makeUrl (path, auth);
123
- http_->begin (host.c_str (),kFirebasePort , url.c_str (),true ,kFirebaseFingerprint );
124
- status_ = http_->sendRequest (method, (uint8_t *)value.c_str (), value.length ());
125
- if (isError ()) {
126
- error_message_ =String (method) +" " + url +" :" +HTTPClient::errorToString (status_);
127
- }
128
- }
129
157
130
- FirebaseCall::FirebaseCall (const String& host,const String& auth,
131
- const char * method,const String& path,
132
- HTTPClient* http) : FirebaseCall(host, auth, method, path," " , http) {
133
- }
134
-
135
- bool FirebaseCall::isOk ()const {
136
- return status_ == HTTP_CODE_OK;
137
- }
138
-
139
- bool FirebaseCall::isError ()const {
140
- return status_ <0 ;
141
- }
142
-
143
- StringFirebaseCall::errorMessage ()const {
144
- return error_message_;
145
- }
146
-
147
- StringFirebaseCall::rawResponse () {
148
- return http_->getString ();
149
- }