CURLOPT_NOBODY.3 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. .\" generated by cd2nroff 0.1 from CURLOPT_NOBODY.md
  2. .TH CURLOPT_NOBODY 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_NOBODY \- do the download request without getting the body
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_NOBODY, long opt);
  9. .fi
  10. .SH DESCRIPTION
  11. A long parameter set to 1 tells libcurl to not include the body\-part in the
  12. output when doing what would otherwise be a download. For HTTP(S), this makes
  13. libcurl do a HEAD request. For most other protocols it means just not asking
  14. to transfer the body data.
  15. For HTTP operations when \fICURLOPT_NOBODY(3)\fP has been set, disabling this
  16. option (with 0) makes it a GET again \- only if the method is still set to be
  17. HEAD. The proper way to get back to a GET request is to set
  18. \fICURLOPT_HTTPGET(3)\fP and for other methods, use the POST or UPLOAD
  19. options.
  20. Enabling \fICURLOPT_NOBODY(3)\fP means asking for a download without a body.
  21. If you do a transfer with HTTP that involves a method other than HEAD, you get
  22. a body (unless the resource and server sends a zero byte body for the specific
  23. URL you request).
  24. .SH DEFAULT
  25. 0, the body is transferred
  26. .SH PROTOCOLS
  27. This functionality affects all supported protocols
  28. .SH EXAMPLE
  29. .nf
  30. int main(void)
  31. {
  32. CURL *curl = curl_easy_init();
  33. if(curl) {
  34. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  35. /* get us the resource without a body - use HEAD! */
  36. curl_easy_setopt(curl, CURLOPT_NOBODY, 1L);
  37. /* Perform the request */
  38. curl_easy_perform(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.1
  44. .SH RETURN VALUE
  45. Returns CURLE_OK
  46. .SH SEE ALSO
  47. .BR CURLOPT_HTTPGET (3),
  48. .BR CURLOPT_MIMEPOST (3),
  49. .BR CURLOPT_POSTFIELDS (3),
  50. .BR CURLOPT_REQUEST_TARGET (3),
  51. .BR CURLOPT_UPLOAD (3)