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

NAME

6       CURLOPT_USERAGENT - set 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 zero terminated string as parameter. It will be
15       used to set the User-Agent: header in the  HTTP  request  sent  to  the
16       remote  server.  This  can  be used to fool servers or scripts. You can
17       also 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, "http://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
50libcurl 7.61.1                 December 21, 2016          CURLOPT_USERAGENT(3)
Impressum