curl-library
Re: CURL_EASY_PERFORM error but data transfer works
Date: Thu, 19 Feb 2015 23:23:51 -0500
On 2/19/2015 8:30 PM, Jon wrote:
>
> Thanks Ray for looking into this. I commented out all of the backend
> PHP stuff just to see if anything changed but still received the same
> error msg. (and things keep on working). I’ll turn on VERBOSE and see
> what occurs there.
>
> Note that I’m using build 7.39 via MSVC 11 on Windows 7 x64 as well.
> Back end Apache/Linux and PHP.
>
> Daniel, thanks as well. I will build a new project with just the
> simple HTTP post module and run it separately from my app. Will let
> you know how that goes.
>
I have an idea what may be happening. I was able to reproduce when I
targeted the GUI subsystem. I guessed since you used MessageBox instead
of printf you may be targeting the GUI subsystem. If you have built an
application for the GUI subsystem then by default you don't have a
console or stdout. The easiest way to test this theory is to enable
stdout fd by redirecting to a file. From the console run your app like this:
app.exe > foo
See if you still get that error. libcurl by default uses fwrite to
stdout unless you have set your own write function. Since you are not
interested in the response body you could use a write function that does
nothing except return the bytes handled (all of them):
size_t write_callback(char *ptr, size_t size, size_t nmemb, void
*userdata) {
return size * nmemb;
}
And in your curl_out function add:
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
Now libcurl will use that function instead of fwrite to stdout. For more
on CURLOPT_WRITEFUNCTION see [1]. Also note the libcurl tutorial [2]
which says:
"libcurl offers its own default internal callback that will take care of
the data if you don't set the callback with CURLOPT_WRITEFUNCTION. It
will then simply output the received data to stdout. You can have the
default callback write the data to a different file handle by passing a
'FILE *' to a file opened for writing with the CURLOPT_WRITEDATA option. "
[1]: http://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html
[2]: http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-02-20