git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jacob Helwig <jacob.helwig@gmail.com>
To: "Spencer E. Olson" <olsonse@umich.edu>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Tay Ray Chuan <rctay89@gmail.com>,
	Nick Hengeveld <nickh@reactrix.com>,
	Mark Lodato <lodatom@gmail.com>,
	"Shawn O. Pearce" <spearce@spearce.org>
Subject: Re: [PATCH v4] Allow HTTP user agent string to be modified.
Date: Wed, 11 Aug 2010 13:35:58 -0700	[thread overview]
Message-ID: <AANLkTikzCVAb8YOZQhZ-sd6uhngiAQnhkB-k_JFZMem=@mail.gmail.com> (raw)
In-Reply-To: <1281558725-29938-1-git-send-email-olsonse@umich.edu>

On Wed, Aug 11, 2010 at 13:32, Spencer E. Olson <olsonse@umich.edu> wrote:
> 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_USER_AGENT).  Relevant documentation is added to Documentation/config.txt.
>

Missed switching GIT_USER_AGENT to GIT_HTTP_USER_AGENT here, in the
commit message, but that seems like something easily enough fixed when
applying.

> Signed-off-by: Spencer E. Olson <olsonse@umich.edu>
> ---
>
> All,
>
> This includes the changes suggested by Ray Chuan and by Junio Hamano, with one
> minor additional change:  This changes the internal -DGIT_USER_AGENT to
> -DGIT_HTTP_USER_AGENT.
>
> Since GIT_HTTP_* seems to follow what several of the other HTTP related
> environement variables, I agree that using GIT_HTTP_USER_AGENT is better for the
> user interface (via env variables) than GIT_USER_AGENT.  I would like to
> additionally change the internal token also to GIT_HTTP_USER_AGENT just because
> it is clearer for other developers.
>
>
>  Documentation/config.txt |    9 +++++++++
>  Makefile                 |    2 +-
>  http.c                   |    9 ++++++++-
>  3 files changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/Documentation/config.txt b/Documentation/config.txt
> index f81fb91..7253b71 100644
> --- a/Documentation/config.txt
> +++ b/Documentation/config.txt
> @@ -1243,6 +1243,15 @@ http.noEPSV::
>        support EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'
>        environment variable. Default is false (curl will use EPSV).
>
> +http.useragent::
> +       The HTTP USER_AGENT string presented to an HTTP server.  The default
> +       value represents the version of the client git such as git/1.7.1.
> +       This option allows you to override this value to a more common value
> +       such as Mozilla/4.0.  This may be necessary, for instance, if
> +       connecting through a firewall that restricts HTTP connections to a set
> +       of common USER_AGENT strings (but not including those like git/1.7.1).
> +       Can be overridden by the 'GIT_HTTP_USER_AGENT' environment variable.
> +
>  i18n.commitEncoding::
>        Character encoding the commit messages are stored in; git itself
>        does not care per se, but this information is necessary e.g. when
> diff --git a/Makefile b/Makefile
> index e151516..f84f4a1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1873,7 +1873,7 @@ builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \
>
>  config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
>
> -http.s http.o: EXTRA_CPPFLAGS = -DGIT_USER_AGENT='"git/$(GIT_VERSION)"'
> +http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='"git/$(GIT_VERSION)"'
>
>  ifdef NO_EXPAT
>  http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
> 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);
> --
> 1.7.0.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

  reply	other threads:[~2010-08-11 20:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-07  3:34 [PATCH v2] Allow HTTP user agent string to be modified Spencer E. Olson
2010-08-07  8:34 ` Ævar Arnfjörð Bjarmason
2010-08-07 17:29   ` Spencer E. Olson
2010-08-07 17:39     ` Ævar Arnfjörð Bjarmason
2010-08-08  2:49     ` Tay Ray Chuan
2010-08-08  2:51 ` Tay Ray Chuan
2010-08-08  3:57   ` Spencer E. Olson
2010-08-11  5:24   ` [PATCH v3] " Spencer E. Olson
2010-08-11  8:04     ` Tay Ray Chuan
2010-08-11 20:08     ` Junio C Hamano
2010-08-11 20:32       ` [PATCH v4] " Spencer E. Olson
2010-08-11 20:35         ` Jacob Helwig [this message]
2010-08-11 20:40           ` [PATCH v5] " Spencer E. Olson
2010-08-12 17:23             ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to='AANLkTikzCVAb8YOZQhZ-sd6uhngiAQnhkB-k_JFZMem=@mail.gmail.com' \
    --to=jacob.helwig@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lodatom@gmail.com \
    --cc=nickh@reactrix.com \
    --cc=olsonse@umich.edu \
    --cc=rctay89@gmail.com \
    --cc=spearce@spearce.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).