CURLOPT_IGNORE_CONTENT_LENGTH.md (1709B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLOPT_IGNORE_CONTENT_LENGTH 5 Section: 3 6 Source: libcurl 7 Protocol: 8 - HTTP 9 - FTP 10 See-also: 11 - CURLOPT_HTTP_VERSION (3) 12 - CURLOPT_MAXFILESIZE_LARGE (3) 13 Added-in: 7.14.1 14 --- 15 16 # NAME 17 18 CURLOPT_IGNORE_CONTENT_LENGTH - ignore content length 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_IGNORE_CONTENT_LENGTH, 26 long ignore); 27 ~~~ 28 29 # DESCRIPTION 30 31 If *ignore* is set to 1L, ignore the Content-Length header in the HTTP 32 response and ignore asking for or relying on it for FTP transfers. 33 34 This is useful for doing HTTP transfers with ancient web servers which report 35 incorrect content length for files over 2 gigabytes. If this option is used, 36 curl cannot accurately report progress, and it instead stops the download when 37 the server ends the connection. 38 39 It is also useful with FTP when for example the file is growing while the 40 transfer is in progress which otherwise unconditionally causes libcurl to 41 report error. 42 43 Only use this option if strictly necessary. 44 45 # DEFAULT 46 47 0 48 49 # %PROTOCOLS% 50 51 # EXAMPLE 52 53 ~~~c 54 int main(void) 55 { 56 CURL *curl = curl_easy_init(); 57 if(curl) { 58 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 59 60 /* we know the server is silly, ignore content-length */ 61 curl_easy_setopt(curl, CURLOPT_IGNORE_CONTENT_LENGTH, 1L); 62 63 curl_easy_perform(curl); 64 } 65 } 66 ~~~ 67 68 # HISTORY 69 70 Support for FTP added in 7.46.0. 71 72 # %AVAILABILITY% 73 74 # RETURN VALUE 75 76 curl_easy_setopt(3) returns a CURLcode indicating success or error. 77 78 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 79 libcurl-errors(3).