xref: /aosp_15_r20/external/curl/docs/libcurl/libcurl-easy.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerTitle: libcurl-easy
5*6236dae4SAndroid Build Coastguard WorkerSection: 3
6*6236dae4SAndroid Build Coastguard WorkerSource: libcurl
7*6236dae4SAndroid Build Coastguard WorkerSee-also:
8*6236dae4SAndroid Build Coastguard Worker  - curl_easy_cleanup (3)
9*6236dae4SAndroid Build Coastguard Worker  - curl_easy_init (3)
10*6236dae4SAndroid Build Coastguard Worker  - curl_easy_setopt (3)
11*6236dae4SAndroid Build Coastguard Worker  - libcurl (3)
12*6236dae4SAndroid Build Coastguard Worker  - libcurl-errors (3)
13*6236dae4SAndroid Build Coastguard Worker  - libcurl-multi (3)
14*6236dae4SAndroid Build Coastguard WorkerProtocol:
15*6236dae4SAndroid Build Coastguard Worker  - All
16*6236dae4SAndroid Build Coastguard WorkerAdded-in: 7.1
17*6236dae4SAndroid Build Coastguard Worker---
18*6236dae4SAndroid Build Coastguard Worker
19*6236dae4SAndroid Build Coastguard Worker# NAME
20*6236dae4SAndroid Build Coastguard Worker
21*6236dae4SAndroid Build Coastguard Workerlibcurl-easy - easy interface overview
22*6236dae4SAndroid Build Coastguard Worker
23*6236dae4SAndroid Build Coastguard Worker# DESCRIPTION
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerWhen using libcurl's "easy" interface you init your session and get a handle
26*6236dae4SAndroid Build Coastguard Worker(often referred to as an "easy handle"), which you use as input to the easy
27*6236dae4SAndroid Build Coastguard Workerinterface functions you use. Use curl_easy_init(3) to get the handle.
28*6236dae4SAndroid Build Coastguard Worker
29*6236dae4SAndroid Build Coastguard WorkerYou continue by setting all the options you want in the upcoming transfer, the
30*6236dae4SAndroid Build Coastguard Workermost important among them is the URL itself (you cannot transfer anything
31*6236dae4SAndroid Build Coastguard Workerwithout a specified URL). You might want to set some callbacks as well that
32*6236dae4SAndroid Build Coastguard Workerare called from the library when data is available etc. For example
33*6236dae4SAndroid Build Coastguard WorkerCURLOPT_WRITEFUNCTION(3). curl_easy_setopt(3) is used for all this.
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard WorkerCURLOPT_URL(3) is the only option you really must set, as otherwise there can
36*6236dae4SAndroid Build Coastguard Workerbe no transfer. Another commonly used option is CURLOPT_VERBOSE(3) that helps
37*6236dae4SAndroid Build Coastguard Workeryou see what libcurl is doing under the hood, which is useful when debugging
38*6236dae4SAndroid Build Coastguard Workerfor example. The curl_easy_setopt(3) man page has a full index of the over 300
39*6236dae4SAndroid Build Coastguard Workeravailable options.
40*6236dae4SAndroid Build Coastguard Worker
41*6236dae4SAndroid Build Coastguard WorkerIf you at any point would like to blank all previously set options for a
42*6236dae4SAndroid Build Coastguard Workersingle easy handle, you can call curl_easy_reset(3) and you can also make a
43*6236dae4SAndroid Build Coastguard Workerclone of an easy handle (with all its set options) using
44*6236dae4SAndroid Build Coastguard Workercurl_easy_duphandle(3).
45*6236dae4SAndroid Build Coastguard Worker
46*6236dae4SAndroid Build Coastguard WorkerWhen all is setup, you tell libcurl to perform the transfer using
47*6236dae4SAndroid Build Coastguard Workercurl_easy_perform(3). It performs the entire transfer operation and does not
48*6236dae4SAndroid Build Coastguard Workerreturn until it is done (successfully or not).
49*6236dae4SAndroid Build Coastguard Worker
50*6236dae4SAndroid Build Coastguard WorkerAfter the transfer has been made, you can set new options and make another
51*6236dae4SAndroid Build Coastguard Workertransfer, or if you are done, cleanup the session by calling
52*6236dae4SAndroid Build Coastguard Workercurl_easy_cleanup(3). If you want persistent connections, you do not cleanup
53*6236dae4SAndroid Build Coastguard Workerimmediately, but instead run ahead and perform other transfers using the same
54*6236dae4SAndroid Build Coastguard Workereasy handle.
55