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