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:
parent
283bf7e87c
commit
55f790ebe4
1 changed files with 6 additions and 1 deletions
|
@ -157,7 +157,7 @@ static int curl_download_internal(const char *url, const char *localpath,
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
FILE *localf = NULL;
|
FILE *localf = NULL;
|
||||||
char *destfile, *tempfile;
|
char *useragent, *destfile, *tempfile;
|
||||||
char hostname[256]; /* RFC1123 states applications should support this length */
|
char hostname[256]; /* RFC1123 states applications should support this length */
|
||||||
struct stat st;
|
struct stat st;
|
||||||
long httpresp, timecond, remote_time, local_time;
|
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_PROGRESSFUNCTION, curl_progress);
|
||||||
curl_easy_setopt(handle->curl, CURLOPT_PROGRESSDATA, (void*)&dlfile);
|
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) {
|
if(!force && stat(destfile, &st) == 0) {
|
||||||
/* assume its a sync, so we're starting from scratch. but, only download
|
/* assume its a sync, so we're starting from scratch. but, only download
|
||||||
* our local is out of date. */
|
* our local is out of date. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue