Skip to content

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Alba0404
Copy link

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.

@Alba0404 Alba0404 force-pushed the ESP8266HTTPClient/Examples/PostHttpsClient branch from 1408805 to d215f57 Compare June 29, 2021 10:54
std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
client->setInsecure(); // Ignore SSL certificate
//client->setFingerprint(fingerprint); //Use SSL
HTTPClient https;
Copy link
Collaborator

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 and https in stack ?

Copy link
Author

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

Copy link
Collaborator

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 ?

Copy link
Collaborator

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.

@Alba0404 Alba0404 force-pushed the ESP8266HTTPClient/Examples/PostHttpsClient branch from e13bd19 to 2376fa6 Compare July 11, 2021 15:46

std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);
client->setInsecure(); // Ignore SSL certificate
//client->setFingerprint(fingerprint); //Use SSL
Copy link
Collaborator

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.

@d-a-v d-a-v added this to the 3.1 milestone Jul 11, 2021
@d-a-v
Copy link
Collaborator

d-a-v commented Jun 15, 2022

pushing to v4 per still in discussion

@d-a-v d-a-v modified the milestones: 3.1, 4.0.0 Jun 15, 2022
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.

3 participants