xref: /curl/docs/libcurl/libcurl-easy.md (revision e3fe0200)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: libcurl
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
16---
17
18# NAME
19
20libcurl-easy - easy interface overview
21
22# DESCRIPTION
23
24When using libcurl's "easy" interface you init your session and get a handle
25(often referred to as an "easy handle"), which you use as input to the easy
26interface functions you use. Use curl_easy_init(3) to get the handle.
27
28You continue by setting all the options you want in the upcoming transfer, the
29most important among them is the URL itself (you cannot transfer anything
30without a specified URL as you may have figured out yourself). You might want
31to set some callbacks as well that are called from the library when data is
32available etc. curl_easy_setopt(3) is used for all this.
33
34CURLOPT_URL(3) is the only option you really must set, as otherwise
35there can be no transfer. Another commonly used option is
36CURLOPT_VERBOSE(3) that helps you see what libcurl is doing under the
37hood, which is useful when debugging for example. The
38curl_easy_setopt(3) man page has a full index of the almost 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
43make a clone 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
48not return 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
53cleanup immediately, but instead run ahead and perform other transfers using
54the same easy handle.
55