Skip to content

Commit

Permalink
Merge pull request #260 from firebase/force-reuse
Browse files Browse the repository at this point in the history
FirebaseHttpClient: add forceReuse
  • Loading branch information
proppy authored Oct 27, 2017
2 parents e6445d1 + df523c0 commit c73ca0e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/FirebaseHttpClient_Esp8266.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,32 @@
#define USE_ESP_ARDUINO_CORE_2_0_0
#endif

// Firebase now returns `Connection: close` after REST streaming redirection.
//
// Override the built-in ESP8266HTTPClient to *not* close the
// connection if forceReuse it set to `true`.
class ForceReuseHTTPClient : public HTTPClient {
public:
void end() {
if (_forceReuse) {
_canReuse = true;
}
HTTPClient::end();
}
void forceReuse(bool forceReuse) {
_forceReuse = forceReuse;
}
protected:
bool _forceReuse = false;
};

class FirebaseHttpClientEsp8266 : public FirebaseHttpClient {
public:
FirebaseHttpClientEsp8266() {}

void setReuseConnection(bool reuse) override {
http_.setReuse(reuse);
http_.forceReuse(reuse);
}

void begin(const std::string& url) override {
Expand Down Expand Up @@ -64,7 +84,7 @@ class FirebaseHttpClientEsp8266 : public FirebaseHttpClient {
}

private:
HTTPClient http_;
ForceReuseHTTPClient http_;
};

FirebaseHttpClient* FirebaseHttpClient::create() {
Expand Down

0 comments on commit c73ca0e

Please sign in to comment.