Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2df5bd6

Browse files
committed
Added error message back to streaming imp
1 parent2bf3a4f commit2df5bd6

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

‎Firebase.cpp

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,40 @@ FirebaseEventStream Firebase::stream(const String& path) {
5858
returnFirebaseEventStream(host_, auth_, path);
5959
}
6060

61+
/* FirebaseCall*/
62+
63+
FirebaseCall::FirebaseCall(const String& host,const String& auth,
64+
constchar* 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+
constchar* method,const String& path,
76+
HTTPClient* http) : FirebaseCall(host, auth, method, path,"", http) {
77+
}
78+
79+
boolFirebaseCall::isOk()const {
80+
return status_ == HTTP_CODE_OK;
81+
}
82+
83+
boolFirebaseCall::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+
6195
/* FirebaseEventStream*/
6296

6397
FirebaseEventStream::FirebaseEventStream(const String& host,const String& auth,
@@ -81,6 +115,11 @@ FirebaseEventStream::FirebaseEventStream(const String& host, const String& auth,
81115
http_.begin(location,kFirebaseFingerprint);
82116
status_ = http_.sendRequest("GET", (uint8_t*)NULL,0);
83117
}
118+
119+
if (status_ !=200) {
120+
error_message_ ="stream" + location +":"
121+
+HTTPClient::errorToString(status_);
122+
}
84123
}
85124

86125
boolFirebaseEventStream::connected() {
@@ -115,35 +154,4 @@ String FirebaseEventStream::errorMessage() const {
115154
return error_message_;
116155
}
117156

118-
/* FirebaseCall*/
119-
FirebaseCall::FirebaseCall(const String& host,const String& auth,
120-
constchar* 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-
}
129157

130-
FirebaseCall::FirebaseCall(const String& host,const String& auth,
131-
constchar* method,const String& path,
132-
HTTPClient* http) : FirebaseCall(host, auth, method, path,"", http) {
133-
}
134-
135-
boolFirebaseCall::isOk()const {
136-
return status_ == HTTP_CODE_OK;
137-
}
138-
139-
boolFirebaseCall::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-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp