28
28
29
29
#include < Arduino.h>
30
30
#include < esp32-hal-log.h>
31
-
32
- #ifdef HTTPCLIENT_1_1_COMPATIBLE
33
- #include < NetworkClient.h>
34
- #include < NetworkClientSecure.h>
35
- #endif
36
-
37
31
#include < StreamString.h>
38
32
#include < base64.h>
39
-
40
33
#include " HTTPClient.h"
41
34
42
35
// / Cookie jar support
@@ -56,6 +49,7 @@ class TransportTraits {
56
49
}
57
50
};
58
51
52
+ #ifndef HTTPCLIENT_NOSECURE
59
53
class TLSTraits : public TransportTraits {
60
54
public:
61
55
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 {
81
75
const char *_clicert;
82
76
const char *_clikey;
83
77
};
78
+ #endif // HTTPCLIENT_NOSECURE
84
79
#endif // HTTPCLIENT_1_1_COMPATIBLE
85
80
86
81
/* *
@@ -145,7 +140,12 @@ bool HTTPClient::begin(NetworkClient &client, String url) {
145
140
146
141
_port = (protocol == " https" ? 443 : 80 );
147
142
_secure = (protocol == " https" );
143
+
144
+ #ifdef HTTPCLIENT_NOSECURE
145
+ return _secure ? false : beginInternal (url, protocol.c_str ());
146
+ #else
148
147
return beginInternal (url, protocol.c_str ());
148
+ #endif // HTTPCLIENT_NOSECURE
149
149
}
150
150
151
151
/* *
@@ -174,10 +174,16 @@ bool HTTPClient::begin(NetworkClient &client, String host, uint16_t port, String
174
174
_uri = uri;
175
175
_protocol = (https ? " https" : " http" );
176
176
_secure = https;
177
+
178
+ #ifdef HTTPCLIENT_NOSECURE
179
+ return _secure ? false : true ;
180
+ #else
177
181
return true ;
182
+ #endif // HTTPCLIENT_NOSECURE
178
183
}
179
184
180
185
#ifdef HTTPCLIENT_1_1_COMPATIBLE
186
+ #ifndef HTTPCLIENT_NOSECURE
181
187
bool HTTPClient::begin (String url, const char *CAcert) {
182
188
if (_client && !_tcpDeprecated) {
183
189
log_d (" mix up of new and deprecated api" );
@@ -199,6 +205,7 @@ bool HTTPClient::begin(String url, const char *CAcert) {
199
205
200
206
return true ;
201
207
}
208
+ #endif // HTTPCLIENT_NOSECURE
202
209
203
210
/* *
204
211
* parsing the url for all needed parameters
@@ -214,7 +221,11 @@ bool HTTPClient::begin(String url) {
214
221
clear ();
215
222
_port = 80 ;
216
223
if (!beginInternal (url, " http" )) {
224
+ #ifdef HTTPCLIENT_NOSECURE
225
+ return false ;
226
+ #else
217
227
return begin (url, (const char *)NULL );
228
+ #endif // HTTPCLIENT_NOSECURE
218
229
}
219
230
_transportTraits = TransportTraitsPtr (new TransportTraits ());
220
231
if (!_transportTraits) {
@@ -299,6 +310,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri) {
299
310
return true ;
300
311
}
301
312
313
+ #ifndef HTTPCLIENT_NOSECURE
302
314
bool HTTPClient::begin (String host, uint16_t port, String uri, const char *CAcert) {
303
315
if (_client && !_tcpDeprecated) {
304
316
log_d (" mix up of new and deprecated api" );
@@ -338,6 +350,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, const char *CAcer
338
350
_transportTraits = TransportTraitsPtr (new TLSTraits (CAcert, cli_cert, cli_key));
339
351
return true ;
340
352
}
353
+ #endif // HTTPCLIENT_NOSECURE
341
354
#endif // HTTPCLIENT_1_1_COMPATIBLE
342
355
343
356
/* *
0 commit comments