Skip to content

Commit 4d5d0f6

Browse files
committed
Merge pull request #2084 from arduino/ide-1.5.x-httpclient-allow-https
Allows HttpClient to call https urls
2 parents de1e65f + 6182690 commit 4d5d0f6

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

libraries/Bridge/src/HttpClient.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,43 @@
1818

1919
#include "HttpClient.h"
2020

21+
HttpClient::HttpClient() :
22+
insecure(false) {
23+
// Empty
24+
}
25+
2126
unsigned int HttpClient::get(String &url) {
2227
begin("curl");
28+
if (insecure) {
29+
addParameter("-k");
30+
}
2331
addParameter(url);
2432
return run();
2533
}
2634

2735
unsigned int HttpClient::get(const char *url) {
2836
begin("curl");
37+
if (insecure) {
38+
addParameter("-k");
39+
}
2940
addParameter(url);
3041
return run();
3142
}
3243

3344
void HttpClient::getAsynchronously(String &url) {
3445
begin("curl");
46+
if (insecure) {
47+
addParameter("-k");
48+
}
3549
addParameter(url);
3650
runAsynchronously();
3751
}
3852

3953
void HttpClient::getAsynchronously(const char *url) {
4054
begin("curl");
55+
if (insecure) {
56+
addParameter("-k");
57+
}
4158
addParameter(url);
4259
runAsynchronously();
4360
}
@@ -50,4 +67,11 @@ unsigned int HttpClient::getResult() {
5067
return exitValue();
5168
}
5269

70+
void HttpClient::noCheckSSL() {
71+
insecure = true;
72+
}
73+
74+
void HttpClient::checkSSL() {
75+
insecure = false;
76+
}
5377

libraries/Bridge/src/HttpClient.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,19 @@
2323

2424
class HttpClient : public Process {
2525
public:
26+
HttpClient();
2627

2728
unsigned int get(String &url);
2829
unsigned int get(const char * url);
2930
void getAsynchronously(String &url);
3031
void getAsynchronously(const char * url);
3132
boolean ready();
3233
unsigned int getResult();
34+
void noCheckSSL();
35+
void checkSSL();
36+
37+
private:
38+
boolean insecure;
3339

3440
};
3541

0 commit comments

Comments
 (0)