CURLOPT_CUSTOMREQUEST.3 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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.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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_CUSTOMREQUEST 3 "17 Jun 2014" libcurl libcurl
  26. .SH NAME
  27. CURLOPT_CUSTOMREQUEST \- custom request method
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char *request);
  32. .fi
  33. .SH DESCRIPTION
  34. Pass a pointer to a null-terminated string as parameter.
  35. When you change the request method by setting \fICURLOPT_CUSTOMREQUEST(3)\fP
  36. to something, you do not actually change how libcurl behaves or acts in regards
  37. to the particular request method, it will only change the actual string sent
  38. in the request.
  39. Restore to the internal default by setting this to NULL.
  40. This option can be used to specify the request:
  41. .IP HTTP
  42. Instead of GET or HEAD when performing HTTP based requests. This is
  43. particularly useful, for example, for performing an HTTP DELETE request.
  44. For example:
  45. When you tell libcurl to do a HEAD request, but then specify a GET though a
  46. custom request libcurl will still act as if it sent a HEAD. To switch to a
  47. proper HEAD use \fICURLOPT_NOBODY(3)\fP, to switch to a proper POST use
  48. \fICURLOPT_POST(3)\fP or \fICURLOPT_POSTFIELDS(3)\fP and to switch to a proper
  49. GET use \fICURLOPT_HTTPGET(3)\fP.
  50. Many people have wrongly used this option to replace the entire request with
  51. their own, including multiple headers and POST contents. While that might work
  52. in many cases, it will cause libcurl to send invalid requests and it could
  53. possibly confuse the remote server badly. Use \fICURLOPT_POST(3)\fP and
  54. \fICURLOPT_POSTFIELDS(3)\fP to set POST data. Use \fICURLOPT_HTTPHEADER(3)\fP
  55. to replace or extend the set of headers sent by libcurl. Use
  56. \fICURLOPT_HTTP_VERSION(3)\fP to change HTTP version.
  57. .IP FTP
  58. Instead of LIST and NLST when performing FTP directory listings.
  59. .IP IMAP
  60. Instead of LIST when issuing IMAP based requests.
  61. .IP POP3
  62. Instead of LIST and RETR when issuing POP3 based requests.
  63. For example:
  64. When you tell libcurl to use a custom request it will behave like a LIST or
  65. RETR command was sent where it expects data to be returned by the server. As
  66. such \fICURLOPT_NOBODY(3)\fP should be used when specifying commands such as
  67. \fBDELE\fP and \fBNOOP\fP for example.
  68. .IP SMTP
  69. Instead of a \fBHELP\fP or \fBVRFY\fP when issuing SMTP based requests.
  70. For example:
  71. Normally a multi line response is returned which can be used, in conjunction
  72. with \fICURLOPT_MAIL_RCPT(3)\fP, to specify an EXPN request. If the
  73. \fICURLOPT_NOBODY(3)\fP option is specified then the request can be used to
  74. issue \fBNOOP\fP and \fBRSET\fP commands.
  75. The application does not have to keep the string around after setting this
  76. option.
  77. .SH DEFAULT
  78. NULL
  79. .SH PROTOCOLS
  80. HTTP, FTP, IMAP, POP3 and SMTP
  81. .SH EXAMPLE
  82. .nf
  83. CURL *curl = curl_easy_init();
  84. if(curl) {
  85. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/foo.bin");
  86. /* DELETE the given path */
  87. curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
  88. ret = curl_easy_perform(curl);
  89. curl_easy_cleanup(curl);
  90. }
  91. .fi
  92. .SH AVAILABILITY
  93. IMAP is supported since 7.30.0, POP3 since 7.26.0 and SMTP since 7.34.0.
  94. .SH RETURN VALUE
  95. Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or
  96. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  97. .SH "SEE ALSO"
  98. .BR CURLOPT_HTTPHEADER "(3), " CURLOPT_NOBODY "(3), "
  99. .BR CURLOPT_REQUEST_TARGET "(3), "