Skip to content

Allows HttpClient to call https urls #2084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions libraries/Bridge/src/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,43 @@

#include "HttpClient.h"

HttpClient::HttpClient() :
insecure(false) {
// Empty
}

unsigned int HttpClient::get(String &url) {
begin("curl");
if (insecure) {
addParameter("-k");
}
addParameter(url);
return run();
}

unsigned int HttpClient::get(const char *url) {
begin("curl");
if (insecure) {
addParameter("-k");
}
addParameter(url);
return run();
}

void HttpClient::getAsynchronously(String &url) {
begin("curl");
if (insecure) {
addParameter("-k");
}
addParameter(url);
runAsynchronously();
}

void HttpClient::getAsynchronously(const char *url) {
begin("curl");
if (insecure) {
addParameter("-k");
}
addParameter(url);
runAsynchronously();
}
Expand All @@ -50,4 +67,11 @@ unsigned int HttpClient::getResult() {
return exitValue();
}

void HttpClient::noCheckSSL() {
insecure = true;
}

void HttpClient::checkSSL() {
insecure = false;
}

6 changes: 6 additions & 0 deletions libraries/Bridge/src/HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@

class HttpClient : public Process {
public:
HttpClient();

unsigned int get(String &url);
unsigned int get(const char * url);
void getAsynchronously(String &url);
void getAsynchronously(const char * url);
boolean ready();
unsigned int getResult();
void noCheckSSL();
void checkSSL();

private:
boolean insecure;

};

Expand Down