Imported Upstream version 7.59.0
[platform/upstream/curl.git] / docs / libcurl / curl_easy_perform.3
1 .\" **************************************************************************
2 .\" *                                  _   _ ____  _
3 .\" *  Project                     ___| | | |  _ \| |
4 .\" *                             / __| | | | |_) | |
5 .\" *                            | (__| |_| |  _ <| |___
6 .\" *                             \___|\___/|_| \_\_____|
7 .\" *
8 .\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
9 .\" *
10 .\" * This software is licensed as described in the file COPYING, which
11 .\" * you should have received as part of this distribution. The terms
12 .\" * are also available at https://curl.haxx.se/docs/copyright.html.
13 .\" *
14 .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 .\" * copies of the Software, and permit persons to whom the Software is
16 .\" * furnished to do so, under the terms of the COPYING file.
17 .\" *
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
20 .\" *
21 .\" **************************************************************************
22 .TH curl_easy_perform 3 "May 02, 2016" "libcurl 7.59.0" "libcurl Manual"
23
24 .SH NAME
25 curl_easy_perform - perform a blocking file transfer
26 .SH SYNOPSIS
27 .B #include <curl/curl.h>
28 .sp
29 .BI "CURLcode curl_easy_perform(CURL *" easy_handle ");"
30 .ad
31 .SH DESCRIPTION
32 Invoke this function after \fIcurl_easy_init(3)\fP and all the
33 \fIcurl_easy_setopt(3)\fP calls are made, and will perform the transfer as
34 described in the options. It must be called with the same \fBeasy_handle\fP as
35 input as the \fIcurl_easy_init(3)\fP call returned.
36
37 \fIcurl_easy_perform(3)\fP performs the entire request in a blocking manner
38 and returns when done, or if it failed. For non-blocking behavior, see
39 \fIcurl_multi_perform(3)\fP.
40
41 You can do any amount of calls to \fIcurl_easy_perform(3)\fP while using the
42 same \fBeasy_handle\fP. If you intend to transfer more than one file, you are
43 even encouraged to do so. libcurl will then attempt to re-use the same
44 connection for the following transfers, thus making the operations faster,
45 less CPU intense and using less network resources. Just note that you will
46 have to use \fIcurl_easy_setopt(3)\fP between the invokes to set options for
47 the following curl_easy_perform.
48
49 You must never call this function simultaneously from two places using the
50 same \fBeasy_handle\fP. Let the function return first before invoking it
51 another time. If you want parallel transfers, you must use several curl
52 easy_handles.
53
54 While the \fBeasy_handle\fP is added to a multi handle, it cannot be used by
55 \fIcurl_easy_perform(3)\fP.
56 .SH RETURN VALUE
57 CURLE_OK (0) means everything was ok, non-zero means an error occurred as
58 .I <curl/curl.h>
59 defines - see \fIlibcurl-errors(3)\fP. If the \fICURLOPT_ERRORBUFFER(3)\fP was
60 set with \fIcurl_easy_setopt(3)\fP there will be a readable error message in
61 the error buffer when non-zero is returned.
62 .SH EXAMPLE
63 .nf
64 CURL *curl = curl_easy_init();
65 if(curl) {
66   CURLcode res;
67   curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
68   res = curl_easy_perform(curl);
69   curl_easy_cleanup(curl);
70 }
71 .fi
72 .SH "SEE ALSO"
73 .BR curl_easy_init "(3), " curl_easy_setopt "(3), "
74 .BR curl_multi_add_handle "(3), " curl_multi_perform "(3), "
75 .BR libcurl-errors "(3), "
76