curl_easy_perform.3 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_easy_perform 3 "5 Mar 2001" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_easy_perform - perform a blocking file transfer
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLcode curl_easy_perform(CURL *easy_handle);
  31. .fi
  32. .SH DESCRIPTION
  33. Invoke this function after \fIcurl_easy_init(3)\fP and all the
  34. \fIcurl_easy_setopt(3)\fP calls are made, and it performs the transfer as
  35. described in the options. It must be called with the same \fBeasy_handle\fP as
  36. input as the \fIcurl_easy_init(3)\fP call returned.
  37. \fIcurl_easy_perform(3)\fP performs the entire request in a blocking manner
  38. and returns when done, or earlier if it fails. For non-blocking behavior, see
  39. \fIcurl_multi_perform(3)\fP.
  40. You can do any amount of calls to \fIcurl_easy_perform(3)\fP while using the
  41. same \fBeasy_handle\fP. If you intend to transfer more than one file, you are
  42. even encouraged to do so. libcurl will then attempt to re-use the same
  43. connection for the following transfers, thus making the operations faster,
  44. less CPU intense and using less network resources. Just note that you will
  45. have to use \fIcurl_easy_setopt(3)\fP between the invokes to set options for
  46. the following curl_easy_perform.
  47. You must never call this function simultaneously from two places using the
  48. same \fBeasy_handle\fP. Let the function return first before invoking it
  49. another time. If you want parallel transfers, you must use several curl
  50. easy_handles.
  51. A network transfer moves data to a peer or from a peer. An application tells
  52. libcurl how to receive data by setting the \fICURLOPT_WRITEFUNCTION(3)\fP and
  53. \fICURLOPT_WRITEDATA(3)\fP options. To tell libcurl what data to send, there
  54. are a few more alternatives but two common ones are
  55. \fICURLOPT_READFUNCTION(3)\fP and \fICURLOPT_POSTFIELDS(3)\fP.
  56. While the \fBeasy_handle\fP is added to a multi handle, it cannot be used by
  57. \fIcurl_easy_perform(3)\fP.
  58. .SH EXAMPLE
  59. .nf
  60. CURL *curl = curl_easy_init();
  61. if(curl) {
  62. CURLcode res;
  63. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  64. res = curl_easy_perform(curl);
  65. curl_easy_cleanup(curl);
  66. }
  67. .fi
  68. .SH AVAILABILITY
  69. Always
  70. .SH RETURN VALUE
  71. CURLE_OK (0) means everything was OK, non-zero means an error occurred as
  72. .I <curl/curl.h>
  73. defines - see \fIlibcurl-errors(3)\fP. If the \fICURLOPT_ERRORBUFFER(3)\fP was
  74. set with \fIcurl_easy_setopt(3)\fP there will be a readable error message in
  75. the error buffer when non-zero is returned.
  76. .SH "SEE ALSO"
  77. .BR curl_easy_init "(3), " curl_easy_setopt "(3), "
  78. .BR curl_multi_add_handle "(3), " curl_multi_perform "(3), "
  79. .BR libcurl-errors "(3), "