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,16 @@ bool HTTPClient::begin(NetworkClient &client, String url) {
145
140
146
141
_port = (protocol == " https" ? 443 : 80 );
147
142
_secure = (protocol == " https" );
148
- return beginInternal (url, protocol.c_str ());
143
+
144
+ #ifdef HTTPCLIENT_NOSECURE
145
+ if (_secure)
146
+ return false ;
147
+ else
148
+ return beginInternal (url, protocol.c_str ());
149
+ #else
150
+ return beginInternal (url, protocol.c_str ());
151
+ #endif // HTTPCLIENT_NOSECURE
152
+
149
153
}
150
154
151
155
/* *
@@ -174,10 +178,16 @@ bool HTTPClient::begin(NetworkClient &client, String host, uint16_t port, String
174
178
_uri = uri;
175
179
_protocol = (https ? " https" : " http" );
176
180
_secure = https;
181
+
182
+ #ifdef HTTPCLIENT_NOSECURE
183
+ if (_secure) return false ;
184
+ #endif // HTTPCLIENT_NOSECURE
185
+
177
186
return true ;
178
187
}
179
188
180
189
#ifdef HTTPCLIENT_1_1_COMPATIBLE
190
+ #ifndef HTTPCLIENT_NOSECURE
181
191
bool HTTPClient::begin (String url, const char *CAcert) {
182
192
if (_client && !_tcpDeprecated) {
183
193
log_d (" mix up of new and deprecated api" );
@@ -199,6 +209,7 @@ bool HTTPClient::begin(String url, const char *CAcert) {
199
209
200
210
return true ;
201
211
}
212
+ #endif // HTTPCLIENT_NOSECURE
202
213
203
214
/* *
204
215
* parsing the url for all needed parameters
@@ -214,6 +225,9 @@ bool HTTPClient::begin(String url) {
214
225
clear ();
215
226
_port = 80 ;
216
227
if (!beginInternal (url, " http" )) {
228
+ #ifdef HTTPCLIENT_NOSECURE
229
+ return false ;
230
+ #endif // HTTPCLIENT_NOSECURE
217
231
return begin (url, (const char *)NULL );
218
232
}
219
233
_transportTraits = TransportTraitsPtr (new TransportTraits ());
@@ -299,6 +313,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri) {
299
313
return true ;
300
314
}
301
315
316
+ #ifndef HTTPCLIENT_NOSECURE
302
317
bool HTTPClient::begin (String host, uint16_t port, String uri, const char *CAcert) {
303
318
if (_client && !_tcpDeprecated) {
304
319
log_d (" mix up of new and deprecated api" );
@@ -338,6 +353,7 @@ bool HTTPClient::begin(String host, uint16_t port, String uri, const char *CAcer
338
353
_transportTraits = TransportTraitsPtr (new TLSTraits (CAcert, cli_cert, cli_key));
339
354
return true ;
340
355
}
356
+ #endif // HTTPCLIENT_NOSECURE
341
357
#endif // HTTPCLIENT_1_1_COMPATIBLE
342
358
343
359
/* *
0 commit comments