CURLOPT_HEADER.3 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. .\" generated by cd2nroff 0.1 from CURLOPT_HEADER.md
  2. .TH CURLOPT_HEADER 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_HEADER \- pass headers to the data stream
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HEADER, long onoff);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass the long value \fIonoff\fP set to 1 to ask libcurl to include the headers
  12. in the write callback (\fICURLOPT_WRITEFUNCTION(3)\fP). This option is
  13. relevant for protocols that actually have headers or other meta\-data (like
  14. HTTP and FTP).
  15. When asking to get the headers passed to the same callback as the body, it is
  16. not possible to accurately separate them again without detailed knowledge
  17. about the protocol in use.
  18. Further: the \fICURLOPT_WRITEFUNCTION(3)\fP callback is limited to only ever
  19. get a maximum of \fICURL_MAX_WRITE_SIZE\fP bytes passed to it (16KB), while a
  20. header can be longer and the \fICURLOPT_HEADERFUNCTION(3)\fP supports getting
  21. called with headers up to \fICURL_MAX_HTTP_HEADER\fP bytes big (100KB).
  22. It is often better to use \fICURLOPT_HEADERFUNCTION(3)\fP to get the header
  23. data separately.
  24. While named confusingly similar, \fICURLOPT_HTTPHEADER(3)\fP is used to set
  25. custom HTTP headers!
  26. .SH DEFAULT
  27. 0
  28. .SH PROTOCOLS
  29. This functionality affects ftp, http, imap, pop3 and smtp
  30. .SH EXAMPLE
  31. .nf
  32. int main(void)
  33. {
  34. CURL *curl = curl_easy_init();
  35. if(curl) {
  36. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  37. curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
  38. curl_easy_perform(curl);
  39. }
  40. }
  41. .fi
  42. .SH AVAILABILITY
  43. Added in curl 7.1
  44. .SH RETURN VALUE
  45. Returns CURLE_OK.
  46. .SH SEE ALSO
  47. .BR CURLOPT_HEADERFUNCTION (3),
  48. .BR CURLOPT_HTTPHEADER (3)