1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_POSTFIELDSIZE_LARGE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLOPT_COPYPOSTFIELDS (3)
9  - CURLOPT_POSTFIELDS (3)
10  - CURLOPT_POSTFIELDSIZE (3)
11Protocol:
12  - HTTP
13Added-in: 7.11.1
14---
15
16# NAME
17
18CURLOPT_POSTFIELDSIZE_LARGE - size of POST data pointed to
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POSTFIELDSIZE_LARGE,
26                          curl_off_t size);
27~~~
28
29# DESCRIPTION
30
31If you want to post static data to the server without having libcurl do a
32strlen() to measure the data size, this option must be used. When this option
33is used you can post fully binary data, which otherwise is likely to fail. If
34this size is set to -1, libcurl uses strlen() to get the size or relies on the
35CURLOPT_READFUNCTION(3) (if used) to signal the end of data.
36
37# DEFAULT
38
39-1
40
41# %PROTOCOLS%
42
43# EXAMPLE
44
45~~~c
46extern char *large_chunk; /* pointer to somewhere */
47
48int main(void)
49{
50  CURL *curl = curl_easy_init();
51  if(curl) {
52    const char *data = large_chunk;
53    curl_off_t length_of_data; /* set somehow */
54
55    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
56
57    /* size of the POST data */
58    curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, length_of_data);
59
60    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
61
62    curl_easy_perform(curl);
63  }
64}
65~~~
66
67# %AVAILABILITY%
68
69# RETURN VALUE
70
71Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
72