GNURLOPT_CUSTOMREQUEST(3)
π GNURLOPT_CUSTOMREQUEST(3) β the "say it your way" option
okay bestie, so this page lives in the curl_easy_setopt options part of the gnurl manual, and it's literally about telling a request what to call itself. buckle up π
β¨ NAME β¨
CURLOPT_CUSTOMREQUEST β custom string for request. that's it, that's the vibe π¦
πΈ SYNOPSIS πΈ
#include <gnurl/curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_CUSTOMREQUEST, char
*request);
π DESCRIPTION π
so you pass a pointer to a null-terminated string as the parameter. easy. π«Ά
here's the tea though: when you change the request method by setting CURLOPT_CUSTOMREQUEST(3) to something, you don't actually change how libcurl behaves or acts in regards to that particular request method. it will only change the actual string sent in the request. like, costume change only β the personality underneath is the same, iykyk π
want to restore to the internal default? set this to NULL. slay.
this option can be used to specify the request for a bunch of protocols:
- HTTP β instead of
GETorHEADwhen performing HTTP based requests. this is particularly useful, for example, for performing an HTTPDELETErequest. π₯
For example:
when you tell libcurl to do a HEAD request, but then specify a GET through a custom request, libcurl will still act as if it sent a HEAD. to switch to a proper HEAD use CURLOPT_NOBODY(3), to switch to a proper POST use CURLOPT_POST(3) or CURLOPT_POSTFIELDS(3) and to switch to a proper GET use CURLOPT_HTTPGET(3).
π¨ and now the callout section, bestie, listen up: many people have wrongly used this option to replace the entire request with their own, including multiple headers and POST contents. while that might work in many cases, it will cause libcurl to send invalid requests and it could possibly confuse the remote server badly. π useCURLOPT_POST(3)andCURLOPT_POSTFIELDS(3)to set POST data. useCURLOPT_HTTPHEADER(3)to replace or extend the set of headers sent by libcurl. useCURLOPT_HTTP_VERSION(3)to change HTTP version. periodt.
- FTP β instead of
LISTandNLSTwhen performing FTP directory listings. π¦ - IMAP β instead of
LISTwhen issuing IMAP based requests. π - POP3 β instead of
LISTandRETRwhen issuing POP3 based requests.
For example:
when you tell libcurl to use a custom request it will behave like a LIST or RETR command was sent where it expects data to be returned by the server. as such CURLOPT_NOBODY(3) should be used when specifying commands such as DELE and NOOP for example.
- SMTP β instead of a
HELPorVRFYwhen issuing SMTP based requests.
For example:
normally a multiline response is returned which can be used, in conjunction with CURLOPT_MAIL_RCPT(3), to specify an EXPN request. if the CURLOPT_NOBODY(3) option is specified then the request can be used to issue NOOP and RSET commands.
and the best part? the application does not have to keep the string around after setting this option. no strings attached, literally π§β¨
π DEFAULT π
NULL
(iconic of her, honestly)
π PROTOCOLS π
HTTP, FTP, IMAP, POP3 and SMTP
β EXAMPLE β
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/foo.bin");
/* DELETE the given path */
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
ret = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
go off, DELETE the given path fr fr π
π¦ AVAILABILITY π¦
IMAP is supported since 7.30.0, POP3 since 7.26.0 and SMTP since 7.34.0. vintage queen behavior, we respect it π
π RETURN VALUE π
Returns CURLE_OK if the option is supported, CURLE_UNKNOWN_OPTION if not, or CURLE_OUT_OF_MEMORY if there was insufficient heap space. π (running out of heap space is not the serve you think it is)
π₯ SEE ALSO π₯
and that's the whole page, bestie π«Ά this one's from libcurl 7.37.0, dated 17 Jun 2014 β a lil throwback, ngl. stay custom, stay cute, and don't confuse the remote server π β¨πΈ
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms