1 .\" **************************************************************************
3 .\" * Project ___| | | | _ \| |
4 .\" * / __| | | | |_) | |
5 .\" * | (__| |_| | _ <| |___
6 .\" * \___|\___/|_| \_\_____|
8 .\" * Copyright (C) 1998 - 2017, 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_CUSTOMREQUEST 3 "June 21, 2017" "libcurl 7.59.0" "curl_easy_setopt options"
26 CURLOPT_CUSTOMREQUEST \- custom string for request
28 #include <curl/curl.h>
30 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *request);
32 Pass a pointer to a zero terminated string as parameter.
34 When you change the request method by setting \fICURLOPT_CUSTOMREQUEST(3)\fP
35 to something, you don't actually change how libcurl behaves or acts in regards
36 to the particular request method, it will only change the actual string sent
39 Restore to the internal default by setting this to NULL.
41 This option can be used to specify the request:
43 Instead of GET or HEAD when performing HTTP based requests. This is
44 particularly useful, for example, for performing a HTTP DELETE request.
48 When you tell libcurl to do a HEAD request, but then specify a GET though a
49 custom request libcurl will still act as if it sent a HEAD. To switch to a
50 proper HEAD use \fICURLOPT_NOBODY(3)\fP, to switch to a proper POST use
51 \fICURLOPT_POST(3)\fP or \fICURLOPT_POSTFIELDS(3)\fP and to switch to a proper
52 GET use \fICURLOPT_HTTPGET(3)\fP.
54 Many people have wrongly used this option to replace the entire request with
55 their own, including multiple headers and POST contents. While that might work
56 in many cases, it will cause libcurl to send invalid requests and it could
57 possibly confuse the remote server badly. Use \fICURLOPT_POST(3)\fP and
58 \fICURLOPT_POSTFIELDS(3)\fP to set POST data. Use \fICURLOPT_HTTPHEADER(3)\fP
59 to replace or extend the set of headers sent by libcurl. Use
60 \fICURLOPT_HTTP_VERSION(3)\fP to change HTTP version.
63 Instead of LIST and NLST when performing FTP directory listings.
65 Instead of LIST when issuing IMAP based requests.
67 Instead of LIST and RETR when issuing POP3 based requests.
71 When you tell libcurl to use a custom request it will behave like a LIST or
72 RETR command was sent where it expects data to be returned by the server. As
73 such \fICURLOPT_NOBODY(3)\fP should be used when specifying commands such as
74 DELE and NOOP for example.
76 Instead of a HELP or VRFY when issuing SMTP based requests.
80 Normally a multiline response is returned which can be used, in conjunction
81 with \fICURLOPT_MAIL_RCPT(3)\fP, to specify an EXPN request. If the
82 \fICURLOPT_NOBODY(3)\fP option is specified then the request can be used to
83 issue NOOP and RSET commands.
85 The application does not have to keep the string around after setting this
90 HTTP, FTP, IMAP, POP3 and SMTP
93 CURL *curl = curl_easy_init();
95 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
97 /* DELETE the given path */
98 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
100 ret = curl_easy_perform(curl);
102 curl_easy_cleanup(curl);
106 IMAP is supported since 7.30.0, POP3 since 7.26.0 and SMTP since 7.34.0.
108 Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
109 CURLE_OUT_OF_MEMORY if there was insufficient heap space.
111 .BR CURLOPT_HTTPHEADER "(3), " CURLOPT_NOBODY "(3), "
112 .BR CURLOPT_REQUEST_TARGET "(3), "