{"thread":{"id":"24463","subject":"[PATCH] Allow the CURL user agent to be specified either by config option http.useragent or by the environment variable GIT_USER_AGENT.","startedAt":"2010-07-21T23:40:17Z","lastAt":"2010-07-21T23:40:17Z","messageCount":1,"participants":["Spencer E. Olson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"145972","messageId":"201007211740.42319.olsonse@umich.edu","threadId":"24463","inReplyTo":null,"subject":"[PATCH] Allow the CURL user agent to be specified either by config option http.useragent or by the environment variable GIT_USER_AGENT.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-07-21T23:40:17Z","receivedAt":"2010-07-21T23:40:17Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"Necessary to get through some firewalls that do not allow but the most common \nUser-Agent strings.\n\n---\n http.c |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 1320c50..abee89e 100644\n--- a/http.c\n+++ b/http.c\n@@ -41,6 +41,7 @@ static long curl_low_speed_time = -1;\n static int curl_ftp_no_epsv;\n static const char *curl_http_proxy;\n static char *user_name, *user_pass;\n+static const char *user_agent = NULL;\n\n #if LIBCURL_VERSION_NUM >= 0x071700\n /* Use CURLOPT_KEYPASSWD as is */\n@@ -196,6 +197,9 @@ static int http_options(const char *var, const char \n*value, void *cb)\n        return 0;\n    }\n\n+   if (!strcmp(\"http.useragent\", var))\n+       return git_config_string(&user_agent, var, value);\n+\n    /* Fall back on the default ones */\n    return git_default_config(var, value, cb);\n }\n@@ -279,7 +283,10 @@ static CURL *get_curl_handle(void)\n    if (getenv(\"GIT_CURL_VERBOSE\"))\n        curl_easy_setopt(result, CURLOPT_VERBOSE, 1);\n\n-   curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n+  if (user_agent != NULL)\n+     curl_easy_setopt(result, CURLOPT_USERAGENT, user_agent);\n+  else\n+     curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n\n    if (curl_ftp_no_epsv)\n        curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n@@ -379,6 +386,7 @@ void http_init(struct remote *remote)\n    set_from_env(&ssl_capath, \"GIT_SSL_CAPATH\");\n #endif\n    set_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n+   set_from_env(&user_agent, \"GIT_USER_AGENT\");\n\n    low_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n    if (low_speed_limit != NULL)\n-- \n1.7.1.1\n"}]}