-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add a PostHttpsClient example in the ESP8266HTTPClient library. #8187
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
base: master
Are you sure you want to change the base?
Add a PostHttpsClient example in the ESP8266HTTPClient library. #8187
Conversation
…266HTTPClient/Examples/PostHttpsClient
1408805
to
d215f57
Compare
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure); | ||
client->setInsecure(); // Ignore SSL certificate | ||
//client->setFingerprint(fingerprint); //Use SSL | ||
HTTPClient https; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For coherency,
https
is already global- why is
client
in heap andhttps
in stack ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- For the
https
var, it was a mistake, I remove the global var. - For the difference heap and stack. I don't know, it was in other examples and it works
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stack (cons: too small or precious), Heap (cons: fragmentation), or global (cons: cannot be released), the debate is never closed.
What about using the same allocation scheme for both client and https ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really want to allocate and leave allocated a WiFiClientSecure either globally or very near the beginning of setup(). This is because the client will allocate memory for itself (~17kb IIRC) but also allocate ~7kb for the SSL stack. Later in the app the heap may have enough space, but be fragmented such that you might have 30kb free but no single block of 17kb or 7kb for the stack or the SSL buffers.
…266HTTPClient/Examples/PostHttpsClient
e13bd19
to
2376fa6
Compare
|
||
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure); | ||
client->setInsecure(); // Ignore SSL certificate | ||
//client->setFingerprint(fingerprint); //Use SSL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is prefered to use secure connections in examples.
You may leave the setInsecure()
commented though.
pushing to v4 per still in discussion |
This PR add an example for the ESP8266HTTPClient library.
This example is a POST request using HTTPS protocol.
It was made using the PostHttpClient and GetHttpsClient examples.