CURLINFO_CONTENT_LENGTH_DOWNLOAD.3 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .\" generated by cd2nroff 0.1 from CURLINFO_CONTENT_LENGTH_DOWNLOAD.md
  2. .TH CURLINFO_CONTENT_LENGTH_DOWNLOAD 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLINFO_CONTENT_LENGTH_DOWNLOAD \- get content\-length of download
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
  9. double *content_length);
  10. .fi
  11. .SH DESCRIPTION
  12. Pass a pointer to a double to receive the content\-length of the download. This
  13. is the value read from the Content\-Length: field. Since 7.19.4, this returns
  14. -1 if the size is not known.
  15. \fICURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3)\fP is a newer replacement that returns a more
  16. sensible variable type.
  17. .SH PROTOCOLS
  18. This functionality affects all supported protocols
  19. .SH EXAMPLE
  20. .nf
  21. int main(void)
  22. {
  23. CURL *curl = curl_easy_init();
  24. if(curl) {
  25. CURLcode res;
  26. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  27. /* Perform the request */
  28. res = curl_easy_perform(curl);
  29. if(!res) {
  30. /* check the size */
  31. double cl;
  32. res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
  33. if(!res) {
  34. printf("Size: %.0f\\n", cl);
  35. }
  36. }
  37. }
  38. }
  39. .fi
  40. .SH DEPRECATED
  41. Deprecated since 7.55.0.
  42. .SH AVAILABILITY
  43. Added in curl 7.6.1
  44. .SH RETURN VALUE
  45. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  46. .SH SEE ALSO
  47. .BR CURLINFO_CONTENT_LENGTH_UPLOAD (3),
  48. .BR curl_easy_getinfo (3),
  49. .BR curl_easy_setopt (3)