pacman/pacman.c: fix setting of useragent string

libcurl doesn't natively honor the HTTP_USER_AGENT environment variable.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dave Reisner 2011-03-17 18:33:34 -04:00 committed by Dan McGee
parent 283bf7e87c
commit 55f790ebe4

View file

@ -157,7 +157,7 @@ static int curl_download_internal(const char *url, const char *localpath,
{
int ret = -1;
FILE *localf = NULL;
char *destfile, *tempfile;
char *useragent, *destfile, *tempfile;
char hostname[256]; /* RFC1123 states applications should support this length */
struct stat st;
long httpresp, timecond, remote_time, local_time;
@ -187,6 +187,11 @@ static int curl_download_internal(const char *url, const char *localpath,
curl_easy_setopt(handle->curl, CURLOPT_PROGRESSFUNCTION, curl_progress);
curl_easy_setopt(handle->curl, CURLOPT_PROGRESSDATA, (void*)&dlfile);
useragent = getenv("HTTP_USER_AGENT");
if (useragent != NULL) {
curl_easy_setopt(handle->curl, CURLOPT_USERAGENT, useragent);
}
if(!force && stat(destfile, &st) == 0) {
/* assume its a sync, so we're starting from scratch. but, only download
* our local is out of date. */