1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.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) 12Protocol: 13 - HTTP 14Added-in: 7.1 15--- 16 17# NAME 18 19CURLOPT_USERAGENT - HTTP user-agent header 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25 26CURLcode curl_easy_setopt(CURL *handle, CURLOPT_USERAGENT, char *ua); 27~~~ 28 29# DESCRIPTION 30 31Pass a pointer to a null-terminated string as parameter. It is used to set the 32User-Agent: header field in the HTTP request sent to the remote server. You 33can also set any custom header with CURLOPT_HTTPHEADER(3). 34 35The application does not have to keep the string around after setting this 36option. 37 38Using this option multiple times makes the last set string override the 39previous ones. Set it to NULL to disable its use again. 40 41# DEFAULT 42 43NULL, no User-Agent: header is used. 44 45# %PROTOCOLS% 46 47# EXAMPLE 48 49~~~c 50int main(void) 51{ 52 CURL *curl = curl_easy_init(); 53 if(curl) { 54 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 55 56 curl_easy_setopt(curl, CURLOPT_USERAGENT, "Dark Secret Ninja/1.0"); 57 58 curl_easy_perform(curl); 59 } 60} 61~~~ 62 63# %AVAILABILITY% 64 65# RETURN VALUE 66 67Returns CURLE_OK if HTTP is supported, CURLE_UNKNOWN_OPTION if not, or 68CURLE_OUT_OF_MEMORY if there was insufficient heap space. 69