Sortix nightly manual
This manual documents Sortix nightly, a development build that has not been officially released. You can instead view this document in the latest official manual.
CURLOPT_TRAILERFUNCTION(3) | Library Functions Manual | CURLOPT_TRAILERFUNCTION(3) |
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
This functionality affects http onlyEXAMPLE
static int trailer_cb(struct curl_slist **tr, void *data)
{
/* libcurl frees the list */
*tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff");
return CURL_TRAILERFUNC_OK;
}
int main(void)
{
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
/* 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_UPLOAD, 1L);
/* Assuming we have a function that returns the data to be pushed
Let that function be read_cb */
curl_easy_setopt(curl, CURLOPT_READFUNCTION, trailer_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 transfer */
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_slist_free_all(headers);
}
}
AVAILABILITY
Added in curl 7.64.0RETURN VALUE
Returns CURLE_OK.SEE ALSO
CURLOPT_TRAILERDATA(3), CURLOPT_WRITEFUNCTION(3)2024-11-21 | libcurl |