git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Spencer E. Olson" <olsonse@umich.edu>
To: git@vger.kernel.org
Cc: "Spencer E. Olson" <olsonse@umich.edu>
Subject: [PATCH] Allow the CURL user agent to be specified either by config option http.useragent or by the environment variable GIT_USER_AGENT.
Date: Wed, 21 Jul 2010 17:40:17 -0600	[thread overview]
Message-ID: <201007211740.42319.olsonse@umich.edu> (raw)

Necessary to get through some firewalls that do not allow but the most common 
User-Agent strings.

---
 http.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/http.c b/http.c
index 1320c50..abee89e 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 = NULL;

 #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,10 @@ 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);
+  if (user_agent != NULL)
+     curl_easy_setopt(result, CURLOPT_USERAGENT, user_agent);
+  else
+     curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);

    if (curl_ftp_no_epsv)
        curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
@@ -379,6 +386,7 @@ void http_init(struct remote *remote)
    set_from_env(&ssl_capath, "GIT_SSL_CAPATH");
 #endif
    set_from_env(&ssl_cainfo, "GIT_SSL_CAINFO");
+   set_from_env(&user_agent, "GIT_USER_AGENT");

    low_speed_limit = getenv("GIT_HTTP_LOW_SPEED_LIMIT");
    if (low_speed_limit != NULL)
-- 
1.7.1.1

                 reply	other threads:[~2010-07-21 23:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201007211740.42319.olsonse@umich.edu \
    --to=olsonse@umich.edu \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).