cpp-httplib for openFrameworks (tested on v0.12.0, cpp-httplib version: v0.18.1)
- openssl is not included in this lib
- you can use ofxOpenSSL3 if you need, and SSL http example is also in it.
- ofxPoco has openssl lib in it, but openssl version is lower than 3.0.0, so it won't work with this lib
See example_http_client. (NOTE: Please use projectGenerator before run it)
#include "ofApp.h"
// need this to SSL support, however, openssl is not included in this lib
// if you really need, you have to config openssl (>= 3.0.0) lib by yourself
//#define CPPHTTPLIB_OPENSSL_SUPPORT
// also need this for windows ofxOpenSSL3
//#define USE_OPENSSL3_INSTEAD_OF_OPENSSL_WIN 1
#include "httplib.h"
//--------------------------------------------------------------
void ofApp::setup(){
ofLogToConsole();
//httplib::Client cli("https://httpbin.org");
httplib::Client cli("http://httpbin.org");
auto res = cli.Get("/ip");
if (res) {
ofLogNotice("ofApp") << "res->status = " << res->status;
ofLogNotice("ofApp") << "res->body = " << res->body;
} else {
ofLogError("ofApp") << "error: " << res.error();
}
}
// Result:
// [notice ] ofApp: res->status = 200
// [notice ] ofApp: res->body = {
// "origin": "xxx.xxx.xxx.xxx"
// }- cpp-httplib: MIT License
NOTE: No specific copyright is claimed for this repository changes (for oF binding), but the Apache License 2.0 or MIT License can be applied if necessary.