Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirebaseArduino: switch to ArduinoHttpClient #353

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

proppy
Copy link
Collaborator

@proppy proppy commented Jun 15, 2018

Preliminary work to port the library to use ArduinoHttpClient.
This will enable the library to be portable across arduino cores implementing the Client Interface.

  • ✔️ compile for esp8266
  • ✔️ compile for esp32
  • ✔️ CRUD tested on esp8266
  • ✔️ CRUD tested on esp32
  • ⚠️ streaming not tested on esp8266
  • ⚠️ streaming not tested on esp32

Note this breaks the following libraries/sketches:

  • FirebaseCloudMessaging
  • contrib/modem
  • contrib/things

And obsolete the following classes:

  • Firebase
  • FirebaseHttpClient

Testing welcome 🎠

Related #344 #220

/cc @ed7coyne @kotl

This allow the library to be portable across arduino core implementing
the Client Interface.

Fixes FirebaseExtended#344
@kotl
Copy link
Collaborator

kotl commented Jun 21, 2018

You may remember this, but I wanted to remind you that for ESP8266 implementation, please be extra careful about our use of workaround for ESP8266 of modifying _canReuse even after it was set to false in

https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp#L1020

Through these lines:
if(headerName.equalsIgnoreCase("Connection")) {
_canReuse = headerValue.equalsIgnoreCase("keep-alive");
}
(Since RTDB tends to not send "keep-alive" value)

We change _canReuse value early enough, so that before HTTPClient::end is called, it is set to true.
However, we can't override HTTPClient::end() since it's not virtual and luckily for us, we never call HTTPClient::end, and it is also not called in HTTPClient implementation, therefore when we call ForceReuseHTTPClient::end, it works.

We will need to have same workaround for ESP8266 implementation using ArduinoHttpClient if RTDB is still acting in the same way.

@proppy
Copy link
Collaborator Author

proppy commented Jun 21, 2018

@kotl Oh right, I forgot about this!

We're lucky as It seems that ArduinoHttpClient header handling doesn't parse "Connection: close":
https://github.com/arduino-libraries/ArduinoHttpClient/blob/master/src/HttpClient.cpp#L763

@proppy
Copy link
Collaborator Author

proppy commented Aug 8, 2018

@kotl did you give it a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants