quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLINFO_CONTENT_LENGTH_DOWNLOAD.md (1549B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLINFO_CONTENT_LENGTH_DOWNLOAD
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLINFO_CONTENT_LENGTH_UPLOAD (3)
      9   - curl_easy_getinfo (3)
     10   - curl_easy_setopt (3)
     11 Protocol:
     12   - All
     13 Added-in: 7.6.1
     14 ---
     15 
     16 # NAME
     17 
     18 CURLINFO_CONTENT_LENGTH_DOWNLOAD - get content-length of download
     19 
     20 # SYNOPSIS
     21 
     22 ~~~c
     23 #include <curl/curl.h>
     24 
     25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD,
     26                            double *content_length);
     27 ~~~
     28 
     29 # DESCRIPTION
     30 
     31 Pass a pointer to a double to receive the content-length of the download. This
     32 is the value read from the Content-Length: field. Since 7.19.4, this returns
     33 -1 if the size is not known.
     34 
     35 CURLINFO_CONTENT_LENGTH_DOWNLOAD_T(3) is a newer replacement that returns a more
     36 sensible variable type.
     37 
     38 # %PROTOCOLS%
     39 
     40 # EXAMPLE
     41 
     42 ~~~c
     43 int main(void)
     44 {
     45   CURL *curl = curl_easy_init();
     46   if(curl) {
     47     CURLcode res;
     48     curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
     49 
     50     /* Perform the request */
     51     res = curl_easy_perform(curl);
     52 
     53     if(!res) {
     54       /* check the size */
     55       double cl;
     56       res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl);
     57       if(!res) {
     58         printf("Size: %.0f\n", cl);
     59       }
     60     }
     61   }
     62 }
     63 ~~~
     64 
     65 # DEPRECATED
     66 
     67 Deprecated since 7.55.0.
     68 
     69 # %AVAILABILITY%
     70 
     71 # RETURN VALUE
     72 
     73 curl_easy_getinfo(3) returns a CURLcode indicating success or error.
     74 
     75 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see
     76 libcurl-errors(3).