1CURLOPT_HEADERDATA(3) curl_easy_setopt options CURLOPT_HEADERDATA(3)
2
3
4
6 CURLOPT_HEADERDATA - pointer to pass to header callback
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADERDATA, void
12 *pointer);
13
15 Pass a pointer to be used to write the header part of the received data
16 to.
17
18 If CURLOPT_WRITEFUNCTION(3) or CURLOPT_HEADERFUNCTION(3) is used,
19 pointer will be passed in to the respective callback.
20
21 If neither of those options are set, pointer must be a valid FILE * and
22 it will be used by a plain fwrite() to write headers to.
23
25 NULL
26
28 All
29
31 struct my_info {
32 int shoesize;
33 char *secret;
34 };
35
36 static size_t header_callback(char *buffer, size_t size,
37 size_t nitems, void *userdata)
38 {
39 struct my_info *i = (struct my_info *)userdata;
40
41 /* now this callback can access the my_info struct */
42
43 return nitems * size;
44 }
45
46 CURL *curl = curl_easy_init();
47 if(curl) {
48 struct my_info my = { 10, "the cookies are in the cupboard" };
49 curl_easy_setopt(curl, CURLOPT_URL, "http://example.com");
50
51 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, header_callback);
52
53 /* pass in custom data to the callback */
54 curl_easy_setopt(curl, CURLOPT_HEADERDATA, &my);
55
56 curl_easy_perform(curl);
57 }
58
60 Always
61
63 Returns CURLE_OK
64
66 CURLOPT_HEADERFUNCTION(3), CURLOPT_WRITEFUNCTION(3),
67
68
69
70libcurl 7.69.1 May 05, 2017 CURLOPT_HEADERDATA(3)