I am using libcurl to retrieve a data from the internet. I haven't found any function that I can use if I cancel the transfer..
This is the scenario im facing.
When curl_easy_perform is executed, it retrieves the data from the server and store it to a file or pointer. curl_easy_perform does not stop until it is able to retrieve the whole data. But, I want to add an option that if the user feels that the data that cURL is retrieving is too long, the user can press a key and cancels the transfer. But I cannot seem to find anything in the cURL library that I could use. I just started using this now. Maybe I missed out something. Does anyone know how to cancel the transfer while curl_easy_perform is executing?
Have a look at this page about setting CURL options, about half way down,
there's information about setting a progress callback function CURLOPT_PROGRESSFUNCTION .
Looks as though that is what you are after
initially, i wrote the response of the server to a file..but i am planning to change my implementation and store the response in a buffer, instead. however, i don't have the size of the file that i will be downloading. I need this to set the size of the buffer. And calling curl_easy_perform, get the size, allocate buffer, and call curl_easy_perform again seems like a waste of resources to me.. =)
is there a way that i will know the size of the file that i will be downloading before calling curl_easy_perform? :)