libcurl-easy.md (2033B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: libcurl-easy 5 Section: 3 6 Source: libcurl 7 See-also: 8 - curl_easy_cleanup (3) 9 - curl_easy_init (3) 10 - curl_easy_setopt (3) 11 - libcurl (3) 12 - libcurl-errors (3) 13 - libcurl-multi (3) 14 Protocol: 15 - All 16 Added-in: 7.1 17 --- 18 19 # NAME 20 21 libcurl-easy - easy interface overview 22 23 # DESCRIPTION 24 25 When using libcurl's "easy" interface you init your session and get a handle 26 (often referred to as an "easy handle"), which you use as input to the easy 27 interface functions you use. Use curl_easy_init(3) to get the handle. 28 29 You continue by setting all the options you want in the upcoming transfer, the 30 most important among them is the URL itself (you cannot transfer anything 31 without a specified URL). You might want to set some callbacks as well that 32 are called from the library when data is available etc. For example 33 CURLOPT_WRITEFUNCTION(3). curl_easy_setopt(3) is used for all this. 34 35 CURLOPT_URL(3) is the only option you really must set, as otherwise there can 36 be no transfer. Another commonly used option is CURLOPT_VERBOSE(3) that helps 37 you see what libcurl is doing under the hood, which is useful when debugging 38 for example. The curl_easy_setopt(3) man page has a full index of the over 300 39 available options. 40 41 If you at any point would like to blank all previously set options for a 42 single easy handle, you can call curl_easy_reset(3) and you can also make a 43 clone of an easy handle (with all its set options) using 44 curl_easy_duphandle(3). 45 46 When all is setup, you tell libcurl to perform the transfer using 47 curl_easy_perform(3). It performs the entire transfer operation and does not 48 return until it is done (successfully or not). 49 50 After the transfer has been made, you can set new options and make another 51 transfer, or if you are done, cleanup the session by calling 52 curl_easy_cleanup(3). If you want persistent connections, you do not cleanup 53 immediately, but instead run ahead and perform other transfers using the same 54 easy handle.