2828
2929#include < Arduino.h>
3030#include < esp32-hal-log.h>
31-
32- #ifdef HTTPCLIENT_1_1_COMPATIBLE
33- #include < NetworkClient.h>
34- #include < NetworkClientSecure.h>
35- #endif
36-
3731#include < StreamString.h>
3832#include < base64.h>
39-
4033#include " HTTPClient.h"
4134
4235// / Cookie jar support
@@ -56,6 +49,7 @@ class TransportTraits {
5649 }
5750};
5851
52+ #ifndef HTTPCLIENT_NOSECURE
5953class TLSTraits : public TransportTraits {
6054public:
6155 TLSTraits (const char *CAcert, const char *clicert = nullptr , const char *clikey = nullptr ) : _cacert(CAcert), _clicert(clicert), _clikey(clikey) {}
@@ -81,6 +75,7 @@ class TLSTraits : public TransportTraits {
8175 const char *_clicert;
8276 const char *_clikey;
8377};
78+ #endif // HTTPCLIENT_NOSECURE
8479#endif // HTTPCLIENT_1_1_COMPATIBLE
8580
8681/* *
@@ -145,7 +140,12 @@ bool HTTPClient::begin(NetworkClient &client, String url) {
145140
146141 _port = (protocol == " https" ? 443 : 80 );
147142 _secure = (protocol == " https" );
143+
144+ #ifdef HTTPCLIENT_NOSECURE
145+ return _secure ? false : beginInternal (url, protocol.c_str ());
146+ #else
148147 return beginInternal (url, protocol.c_str ());
148+ #endif // HTTPCLIENT_NOSECURE
149149}
150150
151151/* *
@@ -174,10 +174,16 @@ bool HTTPClient::begin(NetworkClient &client, String host, uint16_t port, String
174174 _uri = uri;
175175 _protocol = (https ? " https" : " http" );
176176 _secure = https;
177+
178+ #ifdef HTTPCLIENT_NOSECURE
179+ if (_secure) return false ;
180+ #endif // HTTPCLIENT_NOSECURE
181+
177182 return true ;
178183}
179184
180185#ifdef HTTPCLIENT_1_1_COMPATIBLE
186+ #ifndef HTTPCLIENT_NOSECURE
181187bool HTTPClient::begin (String url, const char *CAcert) {
182188 if (_client && !_tcpDeprecated) {
183189 log_d (" mix up of new and deprecated api" );
@@ -199,6 +205,7 @@ bool HTTPClient::begin(String url, const char *CAcert) {
199205
200206 return true ;
201207}
208+ #endif // HTTPCLIENT_NOSECURE
202209
203210/* *
204211 * parsing the url for all needed parameters
@@ -214,6 +221,9 @@ bool HTTPClient::begin(String url) {
214221 clear ();
215222 _port = 80 ;
216223 if (!beginInternal (url, " http" )) {
224+ #ifdef HTTPCLIENT_NOSECURE
225+ return false ;
226+ #endif // HTTPCLIENT_NOSECURE
217227 return begin (url, (const char *)NULL );
218228 }
219229 _transportTraits = TransportTraitsPtr (new TransportTraits ());
@@ -299,6 +309,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri) {
299309 return true ;
300310}
301311
312+ #ifndef HTTPCLIENT_NOSECURE
302313bool HTTPClient::begin (String host, uint16_t port, String uri, const char *CAcert) {
303314 if (_client && !_tcpDeprecated) {
304315 log_d (" mix up of new and deprecated api" );
@@ -338,6 +349,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, const char *CAcer
338349 _transportTraits = TransportTraitsPtr (new TLSTraits (CAcert, cli_cert, cli_key));
339350 return true ;
340351}
352+ #endif // HTTPCLIENT_NOSECURE
341353#endif // HTTPCLIENT_1_1_COMPATIBLE
342354
343355/* *
0 commit comments