summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorSpencer E. Olson <olsonse@umich.edu>2010-08-11 20:40:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-08-11 21:07:31 (GMT)
commitb1d1058cc348a985a6209f920fab0db592dc83de (patch)
tree7ab93f6a533ec1ec72336cd537320de2a0f3f6db /http.c
parent64fdc08dac6694d1e754580e7acb82dfa4988bb9 (diff)
downloadgit-b1d1058cc348a985a6209f920fab0db592dc83de.zip
git-b1d1058cc348a985a6209f920fab0db592dc83de.tar.gz
git-b1d1058cc348a985a6209f920fab0db592dc83de.tar.bz2
Allow HTTP user agent string to be modified.
Some firewalls restrict HTTP connections based on the clients user agent. This commit provides the user the ability to modify the user agent string via either a new config option (http.useragent) or by an environment variable (GIT_HTTP_USER_AGENT). Relevant documentation is added to Documentation/config.txt. Signed-off-by: Spencer E. Olson <olsonse@umich.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'http.c')
-rw-r--r--http.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/http.c b/http.c
index 1320c50..0a5011f 100644
--- a/http.c
+++ b/http.c
@@ -41,6 +41,7 @@ static long curl_low_speed_time = -1;
static int curl_ftp_no_epsv;
static const char *curl_http_proxy;
static char *user_name, *user_pass;
+static const char *user_agent;
#if LIBCURL_VERSION_NUM >= 0x071700
/* Use CURLOPT_KEYPASSWD as is */
@@ -196,6 +197,9 @@ static int http_options(const char *var, const char *value, void *cb)
return 0;
}
+ if (!strcmp("http.useragent", var))
+ return git_config_string(&user_agent, var, value);
+
/* Fall back on the default ones */
return git_default_config(var, value, cb);
}
@@ -279,7 +283,8 @@ static CURL *get_curl_handle(void)
if (getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
- curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);
+ curl_easy_setopt(result, CURLOPT_USERAGENT,
+ user_agent ? user_agent : GIT_HTTP_USER_AGENT);
if (curl_ftp_no_epsv)
curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
@@ -380,6 +385,8 @@ void http_init(struct remote *remote)
#endif
set_from_env(&ssl_cainfo, "GIT_SSL_CAINFO");
+ set_from_env(&user_agent, "GIT_HTTP_USER_AGENT");
+
low_speed_limit = getenv("GIT_HTTP_LOW_SPEED_LIMIT");
if (low_speed_limit != NULL)
curl_low_speed_limit = strtol(low_speed_limit, NULL, 10);