Skip to content

ffunatsu/ofxHttpLib

ofxHttpLib

cpp-httplib for openFrameworks (tested on v0.12.0, cpp-httplib version: v0.18.1)

Notes

  • 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

Usage

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"
// }

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.

About

cpp-httplib for openFrameworks

Topics

Resources

License

Unknown and 2 other licenses found

Licenses found

Unknown
LICENSE.md
Apache-2.0
LICENSE_APACHE
MIT
LICENSE_MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors