1CURLOPT_CUSTOMREQUEST(3)   curl_easy_setopt options   CURLOPT_CUSTOMREQUEST(3)
2
3
4

NAME

6       CURLOPT_CUSTOMREQUEST - custom request method
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *request);
12

DESCRIPTION

14       Pass a pointer to a null-terminated string as parameter.
15
16       When  you change the request method by setting CURLOPT_CUSTOMREQUEST(3)
17       to something, you do not actually change how libcurl behaves or acts in
18       regards  to  the particular request method, it will only change the ac‐
19       tual string sent in the request.
20
21       Restore to the internal default by setting this to NULL.
22
23       This option can be used to specify the request:
24
25       HTTP   Instead of GET or HEAD when performing HTTP based requests. This
26              is  particularly  useful,  for  example,  for performing an HTTP
27              DELETE request.
28
29              For example:
30
31              When you tell libcurl to do a HEAD request, but then  specify  a
32              GET though a custom request libcurl will still act as if it sent
33              a HEAD. To switch to a proper  HEAD  use  CURLOPT_NOBODY(3),  to
34              switch  to  a  proper  POST use CURLOPT_POST(3) or CURLOPT_POST‐
35              FIELDS(3) and to switch to a proper GET use CURLOPT_HTTPGET(3).
36
37              Many people have wrongly used this option to replace the  entire
38              request with their own, including multiple headers and POST con‐
39              tents. While that might  work  in  many  cases,  it  will  cause
40              libcurl  to  send invalid requests and it could possibly confuse
41              the remote server badly. Use CURLOPT_POST(3)  and  CURLOPT_POST‐
42              FIELDS(3) to set POST data. Use CURLOPT_HTTPHEADER(3) to replace
43              or  extend  the  set  of  headers  sent  by  libcurl.  Use  CUR‐
44              LOPT_HTTP_VERSION(3) to change HTTP version.
45
46
47       FTP    Instead of LIST and NLST when performing FTP directory listings.
48
49       IMAP   Instead of LIST when issuing IMAP based requests.
50
51       POP3   Instead of LIST and RETR when issuing POP3 based requests.
52
53              For example:
54
55              When  you  tell  libcurl  to use a custom request it will behave
56              like a LIST or RETR command was sent where it expects data to be
57              returned by the server. As such CURLOPT_NOBODY(3) should be used
58              when specifying commands such as DELE and NOOP for example.
59
60       SMTP   Instead of a HELP or VRFY when issuing SMTP based requests.
61
62              For example:
63
64              Normally a multiline response is returned which can be used,  in
65              conjunction  with  CURLOPT_MAIL_RCPT(3),  to specify an EXPN re‐
66              quest. If the CURLOPT_NOBODY(3) option is specified then the re‐
67              quest can be used to issue NOOP and RSET commands.
68
69              The  application  does  not have to keep the string around after
70              setting this option.
71

DEFAULT

73       NULL
74

PROTOCOLS

76       HTTP, FTP, IMAP, POP3 and SMTP
77

EXAMPLE

79       CURL *curl = curl_easy_init();
80       if(curl) {
81         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
82
83         /* DELETE the given path */
84         curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
85
86         ret = curl_easy_perform(curl);
87
88         curl_easy_cleanup(curl);
89       }
90

AVAILABILITY

92       IMAP is supported since  7.30.0,  POP3  since  7.26.0  and  SMTP  since
93       7.34.0.
94

RETURN VALUE

96       Returns  CURLE_OK  if  the option is supported, CURLE_UNKNOWN_OPTION if
97       not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space.
98

SEE ALSO

100       CURLOPT_HTTPHEADER(3), CURLOPT_NOBODY(3), CURLOPT_REQUEST_TARGET(3),
101
102
103
104libcurl 7.85.0                   May 17, 2022         CURLOPT_CUSTOMREQUEST(3)
Impressum