asterisk: Add macro for curl user agent.

Currently, each module that uses libcurl duplicates the standard
Asterisk curl user agent.

This adds a global macro for the Asterisk user agent used for
curl requests to eliminate this duplication.

ASTERISK-29861 #close

Change-Id: I9fc37935980384b4daf96ae54fa3c9adb962ed2d
This commit is contained in:
Naveen Albert
2022-01-13 14:37:16 +00:00
committed by N A
parent 74742cdb5e
commit 63db7505f2
5 changed files with 6 additions and 13 deletions

View File

@@ -600,8 +600,6 @@ static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *da
return realsize;
}
static const char * const global_useragent = "asterisk-libcurl-agent/1.0";
static int curl_instance_init(void *data)
{
CURL **curl = data;
@@ -612,7 +610,7 @@ static int curl_instance_init(void *data)
curl_easy_setopt(*curl, CURLOPT_NOSIGNAL, 1);
curl_easy_setopt(*curl, CURLOPT_TIMEOUT, 180);
curl_easy_setopt(*curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(*curl, CURLOPT_USERAGENT, global_useragent);
curl_easy_setopt(*curl, CURLOPT_USERAGENT, AST_CURL_USER_AGENT);
return 0;
}