Definition: |
include builtins\libcurl.e
curl_easy_setopt(atom curl, CURLoption option, object parameter) -- or -- CURLcode res = curl_easy_setoptf(atom curl, CURLoption option, object parameter) |
Description: |
Set options for a curl easy handle - a typical application uses several curl_easy_setopt() calls for each transfer.
curl_easy_setopt is used to tell libcurl how to behave, what to do, etc. All options are set with an option followed by a parameter. That parameter can be a long, a function pointer, an object pointer or a curl_off_t, depending on what the specific option expects. Read the appropriate CURLoption entry carefully as bad input values may cause libcurl to behave badly! You can only set one option in each function call. 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. You can optionally reset all options back to internal default with curl_easy_reset. Strings passed to libcurl as 'char *' arguments, are copied by the library; thus the string storage associated to the pointer argument may be overwritten after curl_easy_setopt returns. The only exception to this rule is really CURLOPT_POSTFIELDS, but the alternative that copies the string CURLOPT_COPYPOSTFIELDS has some usage characteristics you need to read up on. The order in which the options are set does not matter. Before version 7.17.0, strings were not copied. Instead the user was forced keep them available until libcurl no longer needed them. The handle is the return code from a curl_easy_init or curl_easy_duphandle call. Return value: CURLE_OK (zero) means that the option was set properly, non-zero means an error occurred - see CURLcode for the full list with descriptions. The procedure version of this routine terminates abruptly in error for any result other than CURLE_OK. If you try to set an option that libcurl does not know about, perhaps because the library is too old to support it or the option was removed in a recent version, this function will return CURLE_UNKNOWN_OPTION. If support for the option was disabled at compile-time, it will return CURLE_NOT_BUILT_IN. |
Example: |
include builtins\libcurl.e curl_global_init() atom curl = curl_easy_init() curl_easy_setopt(curl, CURLOPT_URL, "http://example.com") curl_easy_setopt(curl, CURLOPT_VERBOSE, true) CURLcode res = curl_easy_perform(curl) curl_easy_cleanup(curl) curl_global_cleanup() |
See Also: | SEE ALSO , , , , curl_multi_setopt curl_easy_init, curl_easy_cleanup, curl_easy_reset, curl_easy_getinfo, |