GET
while if you set for example CURLOPT_POSTFIELDS
that will make libcurl use the POST
method. If you set CURLOPT_UPLOAD
to true, libcurl will send a PUT
method in its HTTP request and so on. Asking for CURLOPT_NOBODY
will make libcurl use HEAD
.CURLOPT_CUSTOMREQUEST
. For example, you want to send a DELETE
method to the URL of your choice:http://localhost/file1.txt
, libcurl sends the following request to the server:CURLOPT_POSTFIELDS
to the string "foobar" (6 letters, the quotes only used for visual delimiters here), it would send the following headers:CURLOPT_HTTPHEADER
. Suppose you want a header called Name:
that contains Mr. Smith
:Host:
header is wrong (even though it is derived from the URL you give libcurl), you can tell libcurl your own:Accept:
header. Just provide the header name with nothing to the right sight of the colon:Header;
. So if you want to add a header to the outgoing HTTP request that is just Moo:
with nothing following the colon, you could write it like:Referer:
header (yes, it is misspelled) is a standard HTTP header that tells the server from which URL the user-agent was directed from when it arrived at the URL it now requests. It is a normal header so you can set it yourself with the CURLOPT_HEADER
approach as shown above, or you can use the shortcut known as CURLOPT_REFERER
. Like this:CURLOPT_FOLLOWLOCATION
option, and you still want to have the Referer:
header set to the correct previous URL from where it did the redirect, you can ask libcurl to set that by itself: