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