Annotation of embedaddon/curl/docs/libcurl/opts/CURLOPT_POST.3, revision 1.1.1.1
1.1 misho 1: .\" **************************************************************************
2: .\" * _ _ ____ _
3: .\" * Project ___| | | | _ \| |
4: .\" * / __| | | | |_) | |
5: .\" * | (__| |_| | _ <| |___
6: .\" * \___|\___/|_| \_\_____|
7: .\" *
8: .\" * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
9: .\" *
10: .\" * This software is licensed as described in the file COPYING, which
11: .\" * you should have received as part of this distribution. The terms
12: .\" * are also available at https://curl.haxx.se/docs/copyright.html.
13: .\" *
14: .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15: .\" * copies of the Software, and permit persons to whom the Software is
16: .\" * furnished to do so, under the terms of the COPYING file.
17: .\" *
18: .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19: .\" * KIND, either express or implied.
20: .\" *
21: .\" **************************************************************************
22: .\"
23: .TH CURLOPT_POST 3 "July 22, 2019" "libcurl 7.70.0" "curl_easy_setopt options"
24:
25: .SH NAME
26: CURLOPT_POST \- request an HTTP POST
27: .SH SYNOPSIS
28: #include <curl/curl.h>
29:
30: CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POST, long post);
31: .SH DESCRIPTION
32: A parameter set to 1 tells libcurl to do a regular HTTP post. This will also
33: make the library use a "Content-Type: application/x-www-form-urlencoded"
34: header. (This is by far the most commonly used POST method).
35:
36: Use one of \fICURLOPT_POSTFIELDS(3)\fP or \fICURLOPT_COPYPOSTFIELDS(3)\fP
37: options to specify what data to post and \fICURLOPT_POSTFIELDSIZE(3)\fP or
38: \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP to set the data size.
39:
40: Optionally, you can provide data to POST using the
41: \fICURLOPT_READFUNCTION(3)\fP and \fICURLOPT_READDATA(3)\fP options but then
42: you must make sure to not set \fICURLOPT_POSTFIELDS(3)\fP to anything but
43: NULL. When providing data with a callback, you must transmit it using chunked
44: transfer-encoding or you must set the size of the data with the
45: \fICURLOPT_POSTFIELDSIZE(3)\fP or \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP
46: options. To enable chunked encoding, you simply pass in the appropriate
47: Transfer-Encoding header, see the post-callback.c example.
48:
49: You can override the default POST Content-Type: header by setting your own
50: with \fICURLOPT_HTTPHEADER(3)\fP.
51:
52: Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header.
53: You can disable this header with \fICURLOPT_HTTPHEADER(3)\fP as usual.
54:
55: If you use POST to an HTTP 1.1 server, you can send data without knowing the
56: size before starting the POST if you use chunked encoding. You enable this by
57: adding a header like "Transfer-Encoding: chunked" with
58: \fICURLOPT_HTTPHEADER(3)\fP. With HTTP 1.0 or without chunked transfer, you
59: must specify the size in the request. (Since 7.66.0, libcurl will
60: automatically use chunked encoding for POSTs if the size is unknown.)
61:
62: When setting \fICURLOPT_POST(3)\fP to 1, libcurl will automatically set
63: \fICURLOPT_NOBODY(3)\fP and \fICURLOPT_HTTPGET(3)\fP to 0.
64:
65: If you issue a POST request and then want to make a HEAD or GET using the same
66: re-used handle, you must explicitly set the new request type using
67: \fICURLOPT_NOBODY(3)\fP or \fICURLOPT_HTTPGET(3)\fP or similar.
68: .SH DEFAULT
69: 0, disabled
70: .SH PROTOCOLS
71: HTTP
72: .SH EXAMPLE
73: .nf
74: CURL *curl = curl_easy_init();
75: if(curl) {
76: curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
77: curl_easy_setopt(curl, CURLOPT_POST, 1L);
78:
79: /* set up the read callback with CURLOPT_READFUNCTION */
80:
81: ret = curl_easy_perform(curl);
82:
83: curl_easy_cleanup(curl);
84: }
85: .fi
86: .SH AVAILABILITY
87: Along with HTTP
88: .SH RETURN VALUE
89: Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
90: .SH "SEE ALSO"
91: .BR CURLOPT_POSTFIELDS "(3), " CURLOPT_HTTPPOST "(3), "
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>