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