CURLOPT_TRAILERFUNCTION - Online Linux Manual PageSection : 3
Updated : November 26, 2021
Source : libcurl 7.82.0
Note : curl_easy_setopt options
NAMECURLOPT_TRAILERFUNCTION − callback for sending trailing headers
SYNOPSIS#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);
DESCRIPTIONPass a pointer to a callback function. This callback function will be called once right before sending the final CR LF in an HTTP chunked transfer to fill a list of trailing headers to be sent before finishing the HTTP transfer. You can set the userdata argument with the CURLOPT_TRAILERDATA option. The trailing headers included in the linked list must not be CRLF-terminated, because libcurl will add the appropriate line termination characters after each header item. If you use curl_slist_append to add trailing headers to the curl_slist then libcurl will duplicate the strings, and will free the curl_slist and the duplicates once the trailers have been sent. If one of the trailing headers is not formatted correctly (i.e. HeaderName: headerdata) it will be ignored and an info message will be emitted. The return value can either be CURL_TRAILERFUNC_OK or CURL_TRAILERFUNC_ABORT which would respectively instruct libcurl to either continue with sending the trailers or to abort the request. If you set this option to NULL, then the transfer proceeds as usual without any interruptions.
DEFAULTNULL
PROTOCOLSHTTP
EXAMPLE#include <curl/curl.h> static int trailer_cb(struct curl_slist **tr, void *data) {
/* libcurl will free the list */
*tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff");
return CURL_TRAILERFUNC_OK; } CURL *curl = curl_easy_init(); if(curl) {
/* 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); }
AVAILABILITYThis option was added in curl 7.64.0 and is present if HTTP support is enabled
RETURN VALUEReturns CURLE_OK.
SEE ALSOCURLOPT_TRAILERDATA(3)," 0
Johanes Gumabo
Data Size : 7,603 byte
man-CURLOPT_TRAILERFUNCTION.3Build : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 174,736
Visitor ID : :
Visitor IP : 18.191.233.198 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.