in setup() do this
ofxHttpEvents.addListener(this);
here is an example to POST form data in a thread to a url…
ofxHttpForm form;
form.name = "this_is_my_form";
form.method = OFX_HTTP_POST;
form.action = "[http://localhost/";](http://localhost/";)
form.addFormField("field_name", "field_value");
ofxHttpUtil.addForm( form );
if you have registered the event callback, you will get either a response, a connection error or if unlucky & in windows a crash (a long standing problem).
you need to make two functions in test app to handle those responses
void testApp::newResponse(ofxHttpResponse & response){
printf("new response\n");
printf(response.responseBody);
}
(for receiving the response)
Look at the definition of ofxHttpResponse in ofxHttpUtils for what a response object contains, but basically response.responseBody is the text that was downloaded
for errors…
void testApp::newError(string error){
printf("new error = %s\n", error.c_str());
}
To download text you could just POST an empty form
ofxHttpForm form;
form.name = "emptyform";
form.method = OFX_HTTP_POST;
form.action = "[http://localhost/";](http://localhost/";)
ofxHttpUtil.addForm( form );
or use GET
form.method = OFX_HTTP_GET;
The above examples add the forms to a queue, the addon has a thread running that works its way through the queue, without locking up the app, is the idea.
If you don’t mind it locking up whilst downloading, getUrl() instead.
The addon is early days, and there are definitely some poco issues in windows, but let me know if you have questions / problems