NAME
CURLOPT_TRAILERFUNCTION - callback for sending trailing headersSYNOPSIS
#include <curl.h> int curl_trailer_callback(struct curl_slist ** list, void *userdata); CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERFUNCTION, curl_trailer_callback *func);
DESCRIPTION
Pass a pointer to a callback function.DEFAULT
NULLPROTOCOLS
HTTPEXAMPLE
#include <curl/curl.h>/* libcurl will free the list */
*tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff");
return CURL_TRAILERFUNC_OK; }
/* Set the URL of the request */
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
/* Now set it as a put */
curl_easy_setopt(curl, CURLOPT_PUT, 1L);
/* Assuming we have a function that will return the data to be pushed
Let that function be read_cb */
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Trailer: My-super-awesome-trailer");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
/* Set the trailers filling callback */
curl_easy_setopt(curl, CURLOPT_TRAILERFUNCTION, trailer_cb);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_slist_free_all(headers); }
AVAILABILITY
This option was added in curl 7.64.0 and is present if HTTP support is enabledRETURN VALUE
Returns CURLE_OK.SEE ALSO
CURLOPT_TRAILERDATA(3),January 2, 2023 | libcurl 7.88.1 |