From 55f790ebe49ebf5a7d2084682735fd75f6d4903b Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 17 Mar 2011 18:33:34 -0400 Subject: pacman/pacman.c: fix setting of useragent string libcurl doesn't natively honor the HTTP_USER_AGENT environment variable. Signed-off-by: Dave Reisner Signed-off-by: Dan McGee --- lib/libalpm/dload.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/dload.c') diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c index a6225fa4..482cf11d 100644 --- a/lib/libalpm/dload.c +++ b/lib/libalpm/dload.c @@ -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. */ -- cgit v1.2.3-70-g09d2