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
+ if (_secure) return false ;
180
+ #endif // HTTPCLIENT_NOSECURE
181
+
177
182
return true ;
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,6 +221,9 @@ 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
+ #endif // HTTPCLIENT_NOSECURE
217
227
return begin (url, (const char *)NULL );
218
228
}
219
229
_transportTraits = TransportTraitsPtr (new TransportTraits ());
@@ -299,6 +309,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri) {
299
309
return true ;
300
310
}
301
311
312
+ #ifndef HTTPCLIENT_NOSECURE
302
313
bool HTTPClient::begin (String host, uint16_t port, String uri, const char *CAcert) {
303
314
if (_client && !_tcpDeprecated) {
304
315
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
338
349
_transportTraits = TransportTraitsPtr (new TLSTraits (CAcert, cli_cert, cli_key));
339
350
return true ;
340
351
}
352
+ #endif // HTTPCLIENT_NOSECURE
341
353
#endif // HTTPCLIENT_1_1_COMPATIBLE
342
354
343
355
/* *
0 commit comments