1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 .\" * KIND, either express or implied.
21 .\" **************************************************************************
23 .TH CURLOPT_POST 3 "17 Jun 2014" "libcurl 7.37.0" "curl_easy_setopt options"
25 CURLOPT_POST \- request a HTTP POST
27 #include <curl/curl.h>
29 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_POST, long post);
31 A parameter set to 1 tells libcurl to do a regular HTTP post. This will also
32 make the library use a "Content-Type: application/x-www-form-urlencoded"
33 header. (This is by far the most commonly used POST method).
35 Use one of \fICURLOPT_POSTFIELDS(3)\fP or \fICURLOPT_COPYPOSTFIELDS(3)\fP
36 options to specify what data to post and \fICURLOPT_POSTFIELDSIZE(3)\fP or
37 \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP to set the data size.
39 Optionally, you can provide data to POST using the
40 \fICURLOPT_READFUNCTION(3)\fP and \fICURLOPT_READDATA(3)\fP options but then
41 you must make sure to not set \fICURLOPT_POSTFIELDS(3)\fP to anything but
42 NULL. When providing data with a callback, you must transmit it using chunked
43 transfer-encoding or you must set the size of the data with the
44 \fICURLOPT_POSTFIELDSIZE(3)\fP or \fICURLOPT_POSTFIELDSIZE_LARGE(3)\fP
45 options. To enable chunked encoding, you simply pass in the appropriate
46 Transfer-Encoding header, see the post-callback.c example.
48 You can override the default POST Content-Type: header by setting your own
49 with \fICURLOPT_HTTPHEADER(3)\fP.
51 Using POST with HTTP 1.1 implies the use of a "Expect: 100-continue" header.
52 You can disable this header with \fICURLOPT_HTTPHEADER(3)\fP as usual.
54 If you use POST to a HTTP 1.1 server, you can send data without knowing the
55 size before starting the POST if you use chunked encoding. You enable this by
56 adding a header like "Transfer-Encoding: chunked" with
57 \fICURLOPT_HTTPHEADER(3)\fP. With HTTP 1.0 or without chunked transfer, you
58 must specify the size in the request.
60 When setting \fICURLOPT_POST(3)\fP to 1, it will automatically set
61 \fICURLOPT_NOBODY(3)\fP to 0.
63 If you issue a POST request and then want to make a HEAD or GET using the same
64 re-used handle, you must explicitly set the new request type using
65 \fICURLOPT_NOBODY(3)\fP or \fICURLOPT_HTTPGET(3)\fP or similar.
75 Returns CURLE_OK if HTTP is supported, and CURLE_UNKNOWN_OPTION if not.
77 .BR CURLOPT_POSTFIELDS "(3), " CURLOPT_HTTPPOST "(3), "