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