Post aimed at Roxlu, but anyone else can make suggestions if they know Also good to keep here for the archive.
I decided to revisit libcurl instead of Poco for http stuff due to previous Windows thread crashes. I noticed your ofxCurl is a long way on from what I started playing with a year ago
I am trying to get your addon working with Codeblocks Windows. I donât want/need to compile libcurl, unless its not the right version to use in your addon? (i mean, youve not included mac only or something?)
Anyway, I have so far:
included files from here in my project
\openframeworks\v0.062\addons\ofxCurl\src\
\openframeworks\v0.062\addons\ofxCurl\src\include_codeblocks\
added the search path
added preprocessor defines, i think this is right âŚ
added to the top of ofxCurl.h
#define CURL_STATICLIB #define CURL_DISABLE_LDAP
as in your readme it says:
In Code::Blocks I had to define these two defines to make it
link:
CURL_STATICLIB
CURL_DISABLE_LDAP
So, when I go to build, I get the error:
C:\openframeworks\v0.062\addons\ofxCurl\src\ofxCurlFileDownload.cpp||In member function âbool ofxCurlFileDownload::startDownloading()â:
C:\openframeworks\v0.062\addons\ofxCurl\src\ofxCurlFileDownload.cpp|69|error: âassertâ was not declared in this scope
I donât know the code but as far as I know about macros like this, you can try to just comment the line out, because assert commands are only for debugging (or at least should only be used for that, not for programming logic)
// we use the multi handles because of async-io
multi_curl_handle = curl_multi_init();
//assert(multi_curl_handle!=NULL);
CURLMcode t = curl_multi_add_handle(multi_curl_handle, curl_handle);
Regarding the assert: Itâs used as a safety line, for checking things to make functions safer. In your example, itâs used to make sure that the creation of multi_curl_handle was successful before proceeding. So you donât âneedâ them, but then you donât know when something is wrong (e.g. unsuccessful pointer creation because out-of-memory, or other things), and the code could start to behave unpredictably.
Adding #include or #include assert.h in ofxCurlFileDownload.h should make the error go away, although I donât know why it appeared in the first place - Roxlu would also be affected by this, but obviously is not.
you can catch exceptions from the calling functionâs scope, too⌠thrown exceptions travel up the calling hierarchy until they encounter a catch (stack unwinding, read http://www.learncpp.com/cpp-tutorial/153-exceptions-functions-and-stack-unwinding/)
youâll need a try block somewhere in the hierarchy, but not necessarily in the function where you throw the exception.
I updated the git version. It contains an example on how to post a simple form with some input fields and a file element. I added a function to retrieve the response from the server after posting. See the getPostResponseAsString and getPostResponseAsBuffer.
Both functions return the same data though getPostResponseAsBuffer returns a std::vector which can be handy if you want to parse the result.
but the response says: [{âerrorâ:{âtypeâ:2,âaddressâ:"/",âdescriptionâ:âbody contains invalid jsonâ}}]
it am trying to talk to the philips hue bridge.
Someone in the hue hacking forum said the problem was
âsubmitting the data as form data instead of the request body.â
So how would i use ofxcurl to submit something not as form ?
thx,
stephan.