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

Commit409c806

Browse files
committed
Add support for stable branch of HTTP client library, fixes small whitespace nits.
1 parentfdf18aa commit409c806

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

‎Firebase.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
//
1616
#include"Firebase.h"
1717

18+
// Detect whether stable version of HTTP library is installed instead of
19+
// master branch and patch in missing status and methods.
20+
#ifndef HTTP_CODE_TEMPORARY_REDIRECT
21+
#defineHTTP_CODE_TEMPORARY_REDIRECT307
22+
#defineUSE_STABLE_HTTPCLIENT_CORE
23+
#endif
24+
1825
namespace {
1926
constchar*kFirebaseFingerprint ="7A 54 06 9B DC 7A 25 B3 86 8D 66 53 48 2C 0B 96 42 C7 B3 0A";
2027
constuint16_tkFirebasePort =443;
@@ -74,15 +81,15 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth,
7481
bool followRedirect =false;
7582
if (method =="STREAM") {
7683
method ="GET";
77-
http_->addHeader("Accept","text/event-stream");
84+
http_->addHeader("Accept","text/event-stream");
7885
followRedirect =true;
7986
}
8087

8188
if (followRedirect) {
8289
constchar* headers[] = {"Location"};
8390
http_->collectHeaders(headers,1);
8491
}
85-
92+
8693
int status = http_->sendRequest(method, (uint8_t*)data.c_str(), data.length());
8794

8895
// TODO: Add a max redirect check
@@ -98,7 +105,11 @@ FirebaseCall::FirebaseCall(const String& host, const String& auth,
98105
}
99106

100107
if (status !=200) {
108+
#ifdef USE_STABLE_HTTPCLIENT_CORE
109+
error_ =FirebaseError(status,String(method) +"" + url +":" + status);
110+
#else
101111
error_ =FirebaseError(status,String(method) +"" + url +":" +HTTPClient::errorToString(status));
112+
#endif
102113
}
103114

104115
// if not streaming.
@@ -112,7 +123,6 @@ FirebaseGet::FirebaseGet(const String& host, const String& auth,
112123
const String& path,
113124
HTTPClient* http)
114125
: FirebaseCall(host, auth,"GET", path,"", http) {
115-
116126
if (!error()) {
117127
// TODO: parse json
118128
json_ =response();
@@ -121,10 +131,9 @@ FirebaseGet::FirebaseGet(const String& host, const String& auth,
121131

122132
// FirebaseSet
123133
FirebaseSet::FirebaseSet(const String& host,const String& auth,
124-
const String& path,const String& value,
125-
HTTPClient* http)
134+
const String& path,const String& value,
135+
HTTPClient* http)
126136
: FirebaseCall(host, auth,"PUT", path, value, http) {
127-
128137
if (!error()) {
129138
// TODO: parse json
130139
json_ =response();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp