Manpage of curl_easy_setopt
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);
Options set with this function call are valid for all forthcoming transfers performed using this handle. The options are not in any way reset between transfers, so if you want subsequent transfers with different options, you must change them between the transfers.
NOTE: strings passed to libcurl as 'char *' arguments, will not be copied by the library. Instead you should keep them available until libcurl no longer needs them. Failing to do so will cause very odd behavior or even crashes. libcurl will need them until you call curl_easy_cleanup(3) or you set the same option again to use a different pointer.
The handle is the return code from a curl_easy_init(3) or curl_easy_duphandle(3) call.
You hardly ever want this set in production use, you will almost always want this when you debug/report problems. Another neat option for debugging is the CURLOPT_DEBUGFUNCTION.
NOTE: future versions of libcurl is likely to not have any built-in progress meter at all.
Consider building libcurl with ares support to enable asynchronous DNS lookups. It enables nice timeouts for name resolves without signals.
Set the stream argument with the CURLOPT_WRITEDATA option.
NOTE: you will be passed as much data as possible in all invokes, but you cannot possibly make any assumptions. It may be one byte, it may be thousands. The maximum amount of data that can be passed to the write callback is defined in the curl.h header file: CURL_MAX_WRITE_SIZE.
NOTE: If you're using libcurl as a win32 DLL, you MUST use the CURLOPT_WRITEFUNCTION if you set this option or you will experience crashes.
This option is also known with the older name CURLOPT_FILE, the name CURLOPT_WRITEDATA was introduced in 7.9.7.
NOTE: If you're using libcurl as a win32 DLL, you MUST use a CURLOPT_READFUNCTION if you set this option.
This option is also known with the older name CURLOPT_INFILE, the name CURLOPT_READDATA was introduced in 7.9.7.
Also note that CURLOPT_NOPROGRESS must be set to FALSE to make this function actually get called.
Available curl_infotype values:
NOTE: To use this properly, a non-trivial amount of knowledge of the openssl libraries is necessary. Using this function allows for example to use openssl callbacks to add additional validation code for certificates, and even to change the actual URI of an HTTPS request (example used in the lib509 test case). See also the example section for a replacement of the key, certificate and trust file settings.
Use CURLOPT_VERBOSE and CURLOPT_DEBUGFUNCTION to better debug/trace why errors happen.
Note: if the library does not return an error, the buffer may not have been touched. Do not rely on the contents in those cases.
If the given URL lacks the protocol part ("http://" or "ftp://" etc), it will attempt to guess which protocol to use based on the given host name. If the given protocol of the set URL is not supported, libcurl will return on error (CURLE_UNSUPPORTED_PROTOCOL) when you call curl_easy_perform(3) or curl_multi_perform(3). Use curl_version_info(3) for detailed info on which protocols that are supported.
NOTE: CURLOPT_URL is the only option that must be set before curl_easy_perform(3) is called.
NOTE: when you tell the library to use a HTTP proxy, libcurl will transparently convert operations to HTTP even if you specify a FTP URL etc. This may have an impact on what other features of the library you can use, such as CURLOPT_QUOTE and similar FTP specifics that don't work unless you tunnel through the HTTP proxy. Such tunneling is activated with CURLOPT_HTTPPROXYTUNNEL.
NOTE2: libcurl respects the environment variables http_proxy, ftp_proxy, all_proxy etc, if any of those is set.
WARNING: this option is considered obsolete. Stop using it. Switch over to using the share interface instead! See CURLOPT_SHARE and curl_share_init(3).
Note: libcurl uses a user name (and supplied or prompted password) supplied with CURLOPT_USERPWD in preference to any of the options controlled by this parameter.
Pass a long, set to one of the values described below.
Undefined values of the option will have this effect.
This is the default.
Note: libcurl does not verify that the file has the correct properties set (as the standard Unix ftp client does). It should only be readable by user.
When using HTTP and CURLOPT_FOLLOWLOCATION, libcurl might perform several requests to possibly different hosts. libcurl will only send this user and password information to hosts using the initial host name (unless CURLOPT_UNRESTRICTED_AUTH is set), so if libcurl follows locations to other hosts it will not send the user and password to those. This is enforced to prevent accidental information leakage.
NOTE that you need to build libcurl with a suitable GSS-API library for this to work.
NOTE that you need to build libcurl with SSL support for this option to work.
This is a request, not an order; the server may or may not do it. This option must be set (to any non-NULL value) or else any unsolicited encoding done by the server is ignored. See the special file lib/README.encoding for details.
NOTE: this means that the library will re-send the same request on the new location and follow new Location: headers all the way until no more such headers are returned. CURLOPT_MAXREDIRS can be used to limit the number of redirects libcurl will follow.
This POST is a normal application/x-www-form-urlencoded kind (and libcurl will set that Content-Type by default when this option is used), which is the most commonly used one by HTML forms. See also the CURLOPT_POST. Using CURLOPT_POSTFIELDS implies CURLOPT_POST.
Note: to make multipart/formdata posts (aka rfc1867-posts), check out the CURLOPT_HTTPPOST option.
The first line in a request (usually containing a GET or POST) is not a header and cannot be replaced using this option. Only the lines following the request-line are headers.
NOTE:The most commonly replaced headers have "shortcuts" in the options CURLOPT_COOKIE, CURLOPT_USERAGENT and CURLOPT_REFERER.
The linked list should be a fully valid list of struct curl_slist structs, and be properly filled in. Use curl_slist_append(3) to create the list and curl_slist_free_all(3) to clean up an entire list.
NOTE:The alias itself is not parsed for any version strings. So if your alias is "MYHTTP/9.9", Libcurl will not treat the server as responding with HTTP version 9.9. Instead Libcurl will use the value set by option CURLOPT_HTTP_VERSION.
If you need to set mulitple cookies, you need to set them all using a single option and thus you need to concat them all in one single string. Set multiple cookies in one string like this: "name1=content1; name2=content2;" etc.
Using this option multiple times will only make the latest string override the previously ones.
Given an empty or non-existing file, this option will enable cookies for this curl handle, making it understand and parse received cookies and then use matching cookies in future request.
NOTE: If the cookie jar file can't be created or written to (when the curl_easy_cleanup(3) is called), libcurl will not and cannot report an error for this. Using CURLOPT_VERBOSE or CURLOPT_DEBUGFUNCTION will get a warning to display, but that is the only visible feedback you get about this possibly lethal situation.
You disable PORT again and go back to using the passive version by setting this option to NULL.
This causes an FTP NLST command to be sent. Beware that some FTP servers list only files in their response to NLST; they might not include subdirectories and symbolic links.
NOTE: many people have wrongly used this option to replace the entire request with their own, including multiple headers and POST contents. While that might work in many cases, it will cause libcurl to send invalid requests and it could possibly confuse the remote server badly. Use CURLOPT_POST and CURLOPT_POSTFIELDS to set POST data. Use CURLOPT_HTTPHEADER to replace or extend the set of headers sent by libcurl. Use CURLOPT_HTTP_VERSION to change HTTP version.
NOTE: The file size is not always known prior to download, and for such files this option has no effect even if the file transfer ends up being larger than this given limit. This concerns both FTP and HTTP transfers.
NOTE: The file size is not always known prior to download, and for such files this option has no effect even if the file transfer ends up being larger than this given limit. This concerns both FTP and HTTP transfers.
NOTE: The last modification time of a file is not always known and in such instances this feature will have no effect even if the given time condition would have not been met.
NOTE: this is not recommended to use in unix multi-threaded programs, as it uses signals unless CURLOPT_NOSIGNAL (see above) is set.
When reaching the maximum limit, curl uses the CURLOPT_CLOSEPOLICY to figure out which of the existing connections to close to prevent the number of open connections to increase.
NOTE: if you already have performed transfers with this curl handle, setting a smaller MAXCONNECTS than before may cause open connections to get closed unnecessarily.
NOTE: this is not recommended to use in unix multi-threaded programs, as it uses signals unless CURLOPT_NOSIGNAL (see above) is set.
This option is replaced by CURLOPT_SSLKEYPASSWD and should only be used for backward compatibility. You never needed a pass phrase to load a certificate but you need one to load your private key.
NOTE:The format "ENG" enables you to load the private key from a crypto engine. in this case CURLOPT_SSLKEY is used as an identifier passed to the engine. You have to set the crypto engine with CURLOPT_SSLENGINE.
NOTE:If the crypto device cannot be loaded, CURLE_SSL_ENGINE_NOTFOUND is returned.
NOTE:If the crypto device cannot be set, CURLE_SSL_ENGINE_SETFAILED is returned.
You'll find more details about cipher lists on this URL: http://www.openssl.org/docs/apps/ciphers.html