http: minor whitespace cleanup from f464535b

This commit is contained in:
Daniel Stenberg 2018-12-14 10:20:06 +01:00
parent f464535bfd
commit 04b69c744c
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 19 additions and 39 deletions

View File

@ -21,24 +21,18 @@
.\" ************************************************************************** .\" **************************************************************************
.\" .\"
.TH CURLOPT_TRAILERDATA 3 "14 Aug 2018" "libcurl 7.64.0" "curl_easy_setopt options" .TH CURLOPT_TRAILERDATA 3 "14 Aug 2018" "libcurl 7.64.0" "curl_easy_setopt options"
.SH NAME: .SH NAME:
CURLOPT_TRAILERDATA \- Custom pointer passed to the trailing headers callback CURLOPT_TRAILERDATA \- Custom pointer passed to the trailing headers callback
.SH SYNOPSIS: .SH SYNOPSIS:
#include <curl.h> #include <curl.h>
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERDATA, void *userdata); CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERDATA, void *userdata);
.SH DESCRIPTION: .SH DESCRIPTION:
Data pointer to be passed to the HTTP trailer callback function. Data pointer to be passed to the HTTP trailer callback function.
.SH DEFAULT: .SH DEFAULT:
NULL NULL
.SH PROTOCOLS: .SH PROTOCOLS:
HTTP HTTP
.SH EXAMPLE: .SH EXAMPLE:
.nf .nf
/* Assuming we have a CURL handle in the hndl variable. */ /* Assuming we have a CURL handle in the hndl variable. */
@ -46,12 +40,10 @@ HTTP
struct MyData data; struct MyData data;
curl_easy_setopt(hndl, CURLOPT_TRAILERDATA, &data); curl_easy_setopt(hndl, CURLOPT_TRAILERDATA, &data);
.fi .fi
A more complete example can be found in examples/http_trailers.html A more complete example can be found in examples/http_trailers.html
.SH AVAILABILITY: .SH AVAILABILITY:
This option was added in curl 7.64.0 and is present if HTTP support is enabled This option was added in curl 7.64.0 and is present if HTTP support is enabled
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_TRAILERFUNCTION "(3), " .BR CURLOPT_TRAILERFUNCTION "(3), "

View File

@ -21,17 +21,14 @@
.\" ************************************************************************** .\" **************************************************************************
.\" .\"
.TH CURLOPT_TRAILERFUNCTION 3 "14 Aug 2018" "libcurl 7.64.0" "curl_easy_setopt options" .TH CURLOPT_TRAILERFUNCTION 3 "14 Aug 2018" "libcurl 7.64.0" "curl_easy_setopt options"
.SH NAME: .SH NAME:
CURLOPT_TRAILERFUNCTION \- Set callback for sending trailing headers CURLOPT_TRAILERFUNCTION \- Set callback for sending trailing headers
.SH SYNOPSIS: .SH SYNOPSIS:
#include <curl.h> #include <curl.h>
int curl_trailer_callback(struct curl_slist ** list, void *userdata); int curl_trailer_callback(struct curl_slist ** list, void *userdata);
CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERFUNCTION, curl_trailer_callback *func); CURLcode curl_easy_setopt(CURL *handle, CURLOPT_TRAILERFUNCTION, curl_trailer_callback *func);
.SH DESCRIPTION: .SH DESCRIPTION:
Pass a pointer to a callback function. Pass a pointer to a callback function.
@ -59,54 +56,46 @@ trailers or to abort the request.
If you set this option to NULL, then the transfer proceeds as usual If you set this option to NULL, then the transfer proceeds as usual
without any interruptions. without any interruptions.
.SH DEFAULT: .SH DEFAULT:
NULL NULL
.SH PROTOCOLS: .SH PROTOCOLS:
HTTP HTTP
.SH EXAMPLE: .SH EXAMPLE:
#include <curl/curl.h> #include <curl/curl.h>
static int trailer_cb(struct curl_slist **tr, void *data) static int trailer_cb(struct curl_slist **tr, void *data)
{ {
/* libcurl will free the list */ /* libcurl will free the list */
*tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff"); tr = curl_slist_append(*tr, "My-super-awesome-trailer: trailer-stuff");
(void)data; return CURL_TRAILERFUNC_OK;
return CURL_TRAILERFUNC_OK;
} }
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();
if(curl) { if(curl) {
/* Set the URL of the request */
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/");
/* Now set it as a put */
curl_easy_setopt(curl, CURLOPT_PUT, 1L);
/* Set the URL of the request */ /* Assuming we have a function that will return the data to be pushed
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/"); Let that function be read_cb */
/* Now set it as a put */ curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_cb);
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; struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Trailer: My-super-awsome-trailer"); headers = curl_slist_append(headers, "Trailer: My-super-awsome-trailer");
res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
/* Set the trailers filling callback */ /* Set the trailers filling callback */
curl_easy_setopt(curl, CURLOPT_TRAILERFUNCTION, (curl_trailer_callback)trailer_cb); curl_easy_setopt(curl, CURLOPT_TRAILERFUNCTION, trailer_cb);
/* Perform the request, res will get the return code */ /* Perform the request, res will get the return code */
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
curl_slist_free_all(headers); curl_slist_free_all(headers);
} }
.SH AVAILABILITY: .SH AVAILABILITY:
This option was added in curl 7.64.0 and is present if HTTP support is enabled This option was added in curl 7.64.0 and is present if HTTP support is enabled
.SH "SEE ALSO" .SH "SEE ALSO"
.BR CURLOPT_TRAILERDATA "(3), " .BR CURLOPT_TRAILERDATA "(3), "

View File

@ -103,4 +103,3 @@ test_cleanup:
return (int)res; return (int)res;
} }