CURLOPT_USERAGENT.3 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. .\" generated by cd2nroff 0.1 from CURLOPT_USERAGENT.md
  2. .TH CURLOPT_USERAGENT 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_USERAGENT \- HTTP user\-agent header
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERAGENT, char *ua);
  9. .fi
  10. .SH DESCRIPTION
  11. Pass a pointer to a null\-terminated string as parameter. It is used to set the
  12. User\-Agent: header field in the HTTP request sent to the remote server. You
  13. can also set any custom header with \fICURLOPT_HTTPHEADER(3)\fP.
  14. The application does not have to keep the string around after setting this
  15. option.
  16. .SH DEFAULT
  17. NULL, no User\-Agent: header is used.
  18. .SH PROTOCOLS
  19. This functionality affects http only
  20. .SH EXAMPLE
  21. .nf
  22. int main(void)
  23. {
  24. CURL *curl = curl_easy_init();
  25. if(curl) {
  26. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  27. curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0");
  28. curl_easy_perform(curl);
  29. }
  30. }
  31. .fi
  32. .SH AVAILABILITY
  33. Added in curl 7.1
  34. .SH RETURN VALUE
  35. Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or
  36. CURLE_OUT_OF_MEMORY if there was insufficient heap space.
  37. .SH SEE ALSO
  38. .BR CURLOPT_CUSTOMREQUEST (3),
  39. .BR CURLOPT_HTTPHEADER (3),
  40. .BR CURLOPT_REFERER (3),
  41. .BR CURLOPT_REQUEST_TARGET (3)