libcurl

Downloading all files in directory using libcurl

家住魔仙堡 提交于 2019-12-10 20:39:08
问题 I am new to the libcurl and found a way to download a single file from the ftp server. Now my requirement is to download all files in a directory and i guess it was not supported by libcurl. Kindly suggest on libcurl how to download all files in directory or is there any other library similar to libcurl? Thanks in advance. 回答1: You need the list of files on the FTP server. Which isn't straightforward as each FTP server might return a different format of file listing... Anyway, the ftpgetresp

Using libcurl multi interface for consecutive requests for same “easy” handle

拥有回忆 提交于 2019-12-10 20:29:21
问题 My development organization has its own wrapper implementation for threads and select(). The application needs to be enhanced to perform HTTPS requests, and I've decided to use libcurl. After some research, I see that the curl_easy_perform is a blocking call, so I've decided to use the curl_multi_perform approach for non-blocking calls to allow other work in the threads. The HTTPS request will need to be performed periodically to the same URL. I know I can keep the same curl_easy handle and

C++ Non-Blocking ASIO Run

流过昼夜 提交于 2019-12-10 20:13:51
问题 I have created a series of functions that talk to Libcurl Multi and download files asynchronously via ASIO and Boost. Obviously though when I call io_service.run it blocks my main thread when it is run. I have tried to make it non blocking but my app crashes. I was wondering what is the simplest and best approach to running this in the background, in a non-blocking manner and have it call a call-back function when it is done (Like how you can do it in javascript). So I could just go:

send HTTP Get request using Curl in c

妖精的绣舞 提交于 2019-12-10 19:49:14
问题 Please help me to implement an HTTP Get request using curl in C. I need to hit URL with parameters like https://www.googleapis.com/tasks/v1/users?name=pradeep&lastname=singla I used CURLOPT_HTTPHEADER to set parameters with Header but without success. I implemented it like struct curl_slist* contentheader = NULL; contentheader = curl_slist_append(contentheader, "name=pradeep"); contentheader = curl_slist_append(contentheader, "lastname=singla"); curl_easy_setopt(curl, CURLOPT_URL, "https:/

valgrind detects memory leaks when using libcurl (no ssl)

此生再无相见时 提交于 2019-12-10 17:22:39
问题 In my C program I use some basic functions of libcurl. Today I ran valgrind in order to check if I have memory leaks and valgrind went crazy reporting multiple errors. I tracked it basically down to: CURL *curl; CURLcode res; curl = curl_easy_init(); // ... curl_easy_cleanup(curl); If I remove the code that uses libcurl completely, valgrind doesnt report any errors. I already read that there are some problems using valgrind with libcurl and ssl, but I dont fetch any https urls or the like.

curl_multi_exec()

▼魔方 西西 提交于 2019-12-10 15:31:34
问题 I dont understand the PHP cURL function curl_multi_exec() . int curl_multi_exec(handle h, int running) I went through the PHP manual http://www.php.net but don't understand what the variable running does. Searched a lot on Google but didn't find the explanation. Can somebody explain? 回答1: Every time you call it, that variable is assigned to tell you whether the op is still running: curl_multi_exec($ch, $running); After that, $running is non-zero if the operations are still running. If so, you

cURL: Handle multiple asynchronous requests

百般思念 提交于 2019-12-10 14:39:11
问题 I've never really done anything multithreaded or asynchronous in c++, I only used cURL to do single synchronous requests so far. In order to better visualize what I'm trying to do, I wrote a simple Javascript which would do what I want to do with cURL in C++. function AddRequest( method, url, data, id ) { var httpObj = new ActiveXObject("Msxml2.XMLHTTP.6.0"); //new XMLHttpRequest(); httpObj.onreadystatechange = function() { if (httpObj.readyState == 4) ResponseCallback( httpObj, id ); };

Should I set CURLOPT_UPLOAD when I POST file with cURL in PHP?

主宰稳场 提交于 2019-12-10 13:53:54
问题 When I try to set it, it forces the request method to be PUT. Here is what I put in CURLOPT_POSTFIELDS: curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'fileUpload' => '@/home/apache/upload/dummy.sql' )); Or should I ignore the CURLOPT_UPLOAD at all? It said prepare for file upload... 回答1: You can safely ignore it. CURLOPT_POSTFIELDS is just enough to upload a file. The curl library will recognize the file upload and set what's required internally itself. The idea behind CURLOPT_UPLOAD is to tell

Sending “request payload” with libcurl?

十年热恋 提交于 2019-12-10 12:30:17
问题 I am using libcurl. I know how to send form data. I want, however, to send a "request payload" , but I have no idea how to. This is what an example of what I am trying to do, in Chrome Developer Tools: View image Can anyone please help me? 回答1: The command-line version of what you want would be something akin to: curl --header "Content-Type: application/json" --data '{"data":"blob"}' http://address.com (you'll probably want to include cookie information for authentication too) I don't know

CURLOPT_PROGRESSFUNCTION what these parameters mean?

坚强是说给别人听的谎言 提交于 2019-12-10 12:21:56
问题 In libcurl , what the parameters mean in the function called by setting CURLOPT_PROGRESSFUNCTION ? int function(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); Its a lame question I know but the website doesn't seem to describe, or I wasn't able to find :( 回答1: This example might help. To summarize: int function( void *clientp, // this is an unchanged pointer as set with CURLOPT_PROGRESSDATA double dltotal, // the total bytes to be downloaded (or 0 if not