In fact, libcurl has binding in many languages. I prefer C ++, but since curlpp is too troublesome, I directly use libcurl in C language.
> Build OpenSSL
Download OpenSSL from www.openssl.org and install the Perl Environment
1> perl Configure VC-WIN32 --prefix=c:/some/openssl/dir
2> ms\do_ms
3> nmake -f ms\nt.mak (for static library)
Or
3> nmake -f ms\ntdll.mak (for DLL)
> Build libcurl
Download libcurl from http://curl.haxx.se and open vc6curl. DSW compilation.
Do you have use_ssleay and use_openssl in Preprocessor?
>> Certification
Http://curl.haxx.se/docs/sslcerts.html
Libcurlloads A certdata.txt file from mozillaand generates the desired *. CRT file.
'Http: // mxr.mozilla.org/seamonkey/source/security/nss/lib/ckfw/builtins/certdata.txt? Raw = 1'
Run Perl script to generate a ca-bundle.crt using OpenSSL, and then configure curlopt_cainfo:
// Run this script to generate the ca-bundle.crt
S: \ Components \ cplusplus \ curl-7.20.0 \ Lib \ mk-ca-bundle.pl
If the configuration fails, curle_ssl_cacert is returned when you access HTTPS.
> Libcurl
In the simplest example, retrieve the content of the http://curl.haxx.se/docs/thanks.html page and write it to a local file.
Although it is better than Python's urllib.
For easy interface, the basic steps are as follows:
Initialize libcurl
Initialize easy interface
Set the required Option
Execute request
Clear easy interface
Clear libcurl
Code:
// Configure //--------------------------------------------------------------------------------------------------------
// Initialize libcurl
//
Curlcode return_code;
Return_code = curl_global_init (curl_global_win32 );
If (curle_ OK! = Return_code) return;
// Get easy handle
//
Curl * easy_handle = curl_easy_init ();
If (null = easy_handle)
{
Curl_global_cleanup ();
Return;
}
// Open a local file
//
File * fp = fopen ("C: \ thanks.html", "AB + ");
// Set easy handle properties
//
Curl_easy_setopt (easy_handle, curlopt_url, "http://curl.haxx.se/docs/thanks.html ");
Curl_easy_setopt (easy_handle, curlopt_writefunction, & process_data );
Curl_easy_setopt (easy_handle, curlopt_writedata, FP );
// Perform request
//
Curl_easy_perform (easy_handle );
// Close file
//
Fclose (FP );
// Clean up curl
//
Curl_easy_cleanup (easy_handle );
Curl_global_cleanup ();
// Configure //--------------------------------------------------------------------------------------------------------