Headers for httpRequests?

Does anyone know how to send headers as part of an http request? Do I need to extend our poco functionality to make this happen? I don’t see current support in ofxhttpUtils or in the default http of functionality. To do it in terminal using curl it’s just: curl -H “HEADER INFO HERE” URL HERE
Not sure how to get this to work… tips welcome.

i think this is new for 0.9 so only available in master right now:

ofHttpRequest req;
req.headers["header_key"] = value;
ofURLFileLoader loader;
ofHttpResponse res = loader.handleRequest(req);

it’s still missing proper functions so you don’t need to create an ofURLFileLoader and can do async requests but should work.

You can also look into this add-on I’ve been building over time, it allows setting custom headers among other things.

1 Like

Woo hoo! I now have both phoenixperry and phoenix (same human). This lib looks really helpful. The function for headers looks obvious. I’ll try and implement it tonight for SparkCore. Will share back

I’ve used ofxHTTP for spark core, phillips hue, twitter, oauth and other things that require sophisticated client (and server) header control too. It’s also what powers ofSketch.