1CURLOPT_USERAGENT(3)                libcurl               CURLOPT_USERAGENT(3)
2
3
4

NAME

6       CURLOPT_USERAGENT - HTTP user-agent header
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERAGENT, char *ua);
12

DESCRIPTION

14       Pass  a  pointer  to  a null-terminated string as parameter. It will be
15       used to set the User-Agent: header in the HTTP request sent to the  re‐
16       mote  server. This can be used to fool servers or scripts. You can also
17       set any custom header with CURLOPT_HTTPHEADER(3).
18
19       The application does not have to keep the string around  after  setting
20       this option.
21

DEFAULT

23       NULL, no User-Agent: header is used by default.
24

PROTOCOLS

26       HTTP, HTTPS
27

EXAMPLE

29       CURL *curl = curl_easy_init();
30       if(curl) {
31         curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
32
33         curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0");
34
35         curl_easy_perform(curl);
36       }
37

AVAILABILITY

39       As long as HTTP is supported
40

RETURN VALUE

42       Returns  CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or
43       CURLE_OUT_OF_MEMORY if there was insufficient heap space.
44

SEE ALSO

46       CURLOPT_REFERER(3), CURLOPT_HTTPHEADER(3),
47
48
49
50ibcurl 8.2.1                    April 26, 2023            CURLOPT_USERAGENT(3)
Impressum