Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ void loop() {
// wait for WiFi connection
if ((WiFiMulti.run() == WL_CONNECTED)) {

BearSSL::WiFiClientSecure client;
client.setFingerprint(fingerprint);
BearSSL::WiFiClientSecure *client = new BearSSL::WiFiClientSecure;

client->setFingerprint(fingerprint);

HTTPClient https;

Serial.print("[HTTPS] begin...\n");
if (https.begin(client, "https://jigsaw.w3.org/HTTP/connection.html")) { // HTTPS
if (https.begin(*client, "https://jigsaw.w3.org/HTTP/connection.html")) { // HTTPS


Serial.print("[HTTPS] GET...\n");
Expand All @@ -72,6 +73,8 @@ void loop() {
} else {
Serial.printf("[HTTPS] Unable to connect\n");
}

delete client;
}

delay(10000);
Expand Down
15 changes: 8 additions & 7 deletions libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ HTTPClient::HTTPClient()
HTTPClient::~HTTPClient()
{
if(_client) {
_client->stop();
DEBUG_HTTPCLIENT("[HTTP-Client][~HTTPClient] end() not called before destruction of HTTPClient\n");
}
if(_currentHeaders) {
delete[] _currentHeaders;
Expand Down Expand Up @@ -196,7 +196,7 @@ bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String ur
#ifdef HTTPCLIENT_1_1_COMPATIBLE
bool HTTPClient::begin(String url, String httpsFingerprint)
{
if(_client) _canReuse = false;
_canReuse = false;
end();

_port = 443;
Expand All @@ -214,7 +214,7 @@ bool HTTPClient::begin(String url, String httpsFingerprint)

bool HTTPClient::begin(String url, const uint8_t httpsFingerprint[20])
{
if(_client) _canReuse = false;
_canReuse = false;
end();

_port = 443;
Expand All @@ -237,7 +237,7 @@ bool HTTPClient::begin(String url, const uint8_t httpsFingerprint[20])
*/
bool HTTPClient::begin(String url)
{
if(_client) _canReuse = false;
_canReuse = false;
end();

_port = 80;
Expand Down Expand Up @@ -299,7 +299,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol)
#ifdef HTTPCLIENT_1_1_COMPATIBLE
bool HTTPClient::begin(String host, uint16_t port, String uri)
{
if(_client) _canReuse = false;
_canReuse = false;
end();

clear();
Expand All @@ -325,7 +325,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, bool https, Strin

bool HTTPClient::begin(String host, uint16_t port, String uri, String httpsFingerprint)
{
if(_client) _canReuse = false;
_canReuse = false;
end();

clear();
Expand All @@ -343,7 +343,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, String httpsFinge

bool HTTPClient::begin(String host, uint16_t port, String uri, const uint8_t httpsFingerprint[20])
{
if(_client) _canReuse = false;
_canReuse = false;
end();

clear();
Expand All @@ -367,6 +367,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, const uint8_t htt
*/
void HTTPClient::end(void)
{
_canReuse = false;
disconnect();
clear();
}
Expand Down