1CURLOPT_HEADER(3)          curl_easy_setopt options          CURLOPT_HEADER(3)
2
3
4

NAME

6       CURLOPT_HEADER - pass headers to the data stream
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADER, long onoff);
12

DESCRIPTION

14       Pass  the long value onoff set to 1 to ask libcurl to include the head‐
15       ers in the write callback (CURLOPT_WRITEFUNCTION(3)).  This  option  is
16       relevant  for  protocols  that actually have headers or other meta-data
17       (like HTTP and FTP).
18
19       When asking to get the headers passed to the same callback as the body,
20       it  is  not possible to accurately separate them again without detailed
21       knowledge about the protocol in use.
22
23       Further: the CURLOPT_WRITEFUNCTION(3) callback is limited to only  ever
24       get a maximum of CURL_MAX_WRITE_SIZE bytes passed to it (16KB), while a
25       header can be longer and the CURLOPT_HEADERFUNCTION(3) supports getting
26       called with headers up to CURL_MAX_HTTP_HEADER bytes big (100KB).
27
28       It  is  often better to use CURLOPT_HEADERFUNCTION(3) to get the header
29       data separately.
30
31       While named confusingly similar, CURLOPT_HTTPHEADER(3) is used  to  set
32       custom HTTP headers!
33

DEFAULT

35       0
36

PROTOCOLS

38       Most
39

EXAMPLE

41       CURL *curl = curl_easy_init();
42       if(curl) {
43         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
44
45         curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
46
47         curl_easy_perform(curl);
48       }
49

AVAILABILITY

51       Provided in all libcurl versions.
52

RETURN VALUE

54       Returns CURLE_OK.
55

SEE ALSO

57       CURLOPT_HEADERFUNCTION(3), CURLOPT_HTTPHEADER(3),
58
59
60
61libcurl 7.79.1                September 01, 2021             CURLOPT_HEADER(3)
Impressum