1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_USERAGENT 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_CUSTOMREQUEST (3) 9 - CURLOPT_HTTPHEADER (3) 10 - CURLOPT_REFERER (3) 11 - CURLOPT_REQUEST_TARGET (3) 12--- 13 14# NAME 15 16CURLOPT_USERAGENT - HTTP user-agent header 17 18# SYNOPSIS 19 20~~~c 21#include <curl/curl.h> 22 23CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERAGENT, char *ua); 24~~~ 25 26# DESCRIPTION 27 28Pass a pointer to a null-terminated string as parameter. It is used to set the 29User-Agent: header field in the HTTP request sent to the remote server. You 30can also set any custom header with CURLOPT_HTTPHEADER(3). 31 32The application does not have to keep the string around after setting this 33option. 34 35# DEFAULT 36 37NULL, no User-Agent: header is used by default. 38 39# PROTOCOLS 40 41HTTP, HTTPS 42 43# EXAMPLE 44 45~~~c 46int main(void) 47{ 48 CURL *curl = curl_easy_init(); 49 if(curl) { 50 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 51 52 curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0"); 53 54 curl_easy_perform(curl); 55 } 56} 57~~~ 58 59# AVAILABILITY 60 61As long as HTTP is supported 62 63# RETURN VALUE 64 65Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or 66CURLE_OUT_OF_MEMORY if there was insufficient heap space. 67