{"thread":{"id":"24657","subject":"[PATCH v2] Allow HTTP user agent string to be modified.","startedAt":"2010-08-07T03:34:20Z","lastAt":"2010-08-12T17:23:05Z","messageCount":14,"participants":["Spencer E. Olson","Ævar Arnfjörð Bjarmason","Tay Ray Chuan","Junio C Hamano","Jacob Helwig"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"147371","messageId":"1281152060-16736-1-git-send-email-olsonse@umich.edu","threadId":"24657","inReplyTo":null,"subject":"[PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-08-07T03:34:20Z","receivedAt":"2010-08-07T03:34:20Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"Some firewalls restrict HTTP connections based on the clients user agent.  This\ncommit provides the user the ability to modify the user agent string via either\na new config option (http.useragent) or by an environment variable\n(GIT_USER_AGENT).  Relevant documentation is added to Documentation/config.txt.\n\nSigned-off-by: Spencer E. Olson <olsonse@umich.edu>\n---\n\nHi all,\n\nThis is both a reminder and an update for a patch I sent earlier\n(http://article.gmane.org/gmane.comp.version-control.git/151434).\nThis update includes the documentation for the new http.useragent configure\noption and the new GIT_USER_AGENT environement variable.  I hadn't seen any\ncomments on the earlier version of this patch, so I assume it got lost among the\nother list activity.  \n\n Documentation/config.txt |    9 +++++++++\n http.c                   |   11 ++++++++++-\n 2 files changed, 19 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f81fb91..826e816 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,15 @@ http.noEPSV::\n \tsupport EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'\n \tenvironment variable. Default is false (curl will use EPSV).\n \n+http.useragent::\n+\tThe HTTP USER_AGENT string presented to an HTTP server.  The default\n+\tvalue represents the version of the client git such as git/1.7.1.\n+\tThis option allows you to override this value to a more common value\n+\tsuch as Mozilla/4.0.  This may be necessary, for instance, if\n+\tconnecting through a firewall that restricts HTTP connections to a set\n+\tof common USER_AGENT strings (but not including those like git/1.7.1).\n+\tCan be overridden by the 'GIT_USER_AGENT' environment variable.\n+\n i18n.commitEncoding::\n \tCharacter encoding the commit messages are stored in; git itself\n \tdoes not care per se, but this information is necessary e.g. when\ndiff --git a/http.c b/http.c\nindex 1320c50..3a17193 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 *value, void *cb)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(\"http.useragent\", var))\n+\t\treturn git_config_string(&user_agent, var, value);\n+\n \t/* Fall back on the default ones */\n \treturn git_default_config(var, value, cb);\n }\n@@ -279,7 +283,10 @@ static CURL *get_curl_handle(void)\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\tcurl_easy_setopt(result, CURLOPT_VERBOSE, 1);\n \n-\tcurl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n+\tif (user_agent != NULL)\n+\t\tcurl_easy_setopt(result, CURLOPT_USERAGENT, user_agent);\n+\telse\n+\t\tcurl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n \n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n@@ -380,6 +387,8 @@ void http_init(struct remote *remote)\n #endif\n \tset_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n \n+\tset_from_env(&user_agent, \"GIT_USER_AGENT\");\n+\n \tlow_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n \tif (low_speed_limit != NULL)\n \t\tcurl_low_speed_limit = strtol(low_speed_limit, NULL, 10);\n-- \n1.7.1.1\n"},{"id":"147380","messageId":"AANLkTinyohKaACbheGR2Q=-K5sWwv+y1u1-3b2WPzxVh@mail.gmail.com","threadId":"24657","inReplyTo":"1281152060-16736-1-git-send-email-olsonse@umich.edu","subject":"Re: [PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-07T08:34:53Z","receivedAt":"2010-08-07T08:34:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, Aug 7, 2010 at 03:34, Spencer E. Olson <olsonse@umich.edu> wrote:\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\nCan't you just skip the != NULL?:\n\n       if (user_agent)\n               curl_easy_setopt(result, CURLOPT_USERAGENT, user_agent);\n       else\n               curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n"},{"id":"147392","messageId":"1281202184.4815.1.camel@compaq.olson.home","threadId":"24657","inReplyTo":"AANLkTinyohKaACbheGR2Q=-K5sWwv+y1u1-3b2WPzxVh@mail.gmail.com","subject":"Re: [PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-08-07T17:29:44Z","receivedAt":"2010-08-07T17:29:44Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"I would have no problem doing that.  I was just trying to match the\nstyle already present in http.c.  All the other pointer tests in that\nfunction/file are done the same.\n\n\nOn Sat, 2010-08-07 at 08:34 +0000, Ævar Arnfjörð Bjarmason wrote:\n> On Sat, Aug 7, 2010 at 03:34, Spencer E. Olson <olsonse@umich.edu> wrote:\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> Can't you just skip the != NULL?:\n> \n>        if (user_agent)\n>                curl_easy_setopt(result, CURLOPT_USERAGENT, user_agent);\n>        else\n>                curl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n> \n> \n"},{"id":"147391","messageId":"AANLkTimsYJxvHZkj8DNyOLozA4HJ9cwo+v3G_r2UXWz-@mail.gmail.com","threadId":"24657","inReplyTo":"1281202184.4815.1.camel@compaq.olson.home","subject":"Re: [PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-07T17:39:38Z","receivedAt":"2010-08-07T17:39:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Sat, Aug 7, 2010 at 17:29, Spencer E. Olson <olsonse@umich.edu> wrote:\n> I would have no problem doing that.  I was just trying to match the\n> style already present in http.c.  All the other pointer tests in that\n> function/file are done the same.\n\nAh, fair enough. I didn't notice that the rest of http.c already used\nthat style, nevermind then.\n\nIt's best to just keep it consistent, and maybe clean it up in some\nlater patch, but best not to introduce an inconsistency by using a\ndifferent style just for this one.\n\nYour patch looks good.\n"},{"id":"147410","messageId":"AANLkTinuHAnmakLsKujpj6C=eShxe_s+dnwYWg5VfvHy@mail.gmail.com","threadId":"24657","inReplyTo":"1281202184.4815.1.camel@compaq.olson.home","subject":"Re: [PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-08-08T02:49:53Z","receivedAt":"2010-08-08T02:49:53Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"On Sun, Aug 8, 2010 at 1:29 AM, Spencer E. Olson <olsonse@umich.edu> wrote:\n> I would have no problem doing that.  I was just trying to match the\n> style already present in http.c.  All the other pointer tests in that\n> function/file are done the same.\n\nI wouldn't go so far as to say \"all\" - there is quite a mish-mash of\ncheck styles there.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"147411","messageId":"AANLkTi=G=GvxXEh1hGuYQK42cdkMUaFhqxsQ39K=2180@mail.gmail.com","threadId":"24657","inReplyTo":"1281152060-16736-1-git-send-email-olsonse@umich.edu","subject":"Re: [PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-08-08T02:51:55Z","receivedAt":"2010-08-08T02:51:55Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi,\n\nOn Sat, Aug 7, 2010 at 11:34 AM, Spencer E. Olson <olsonse@umich.edu> wrote:\n>[snip]\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\nThis can be skipped, I think.\n\n>[snip]\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\nHmm, perhaps\n\n    curl_easy_setopt(result, CURLOPT_USERAGENT,\n        user_agent ? user_agent : GIT_USER_AGENT);\n\nto replace the if-else?\n\n-- \nCheers,\nRay Chuan\n"},{"id":"147414","messageId":"1281239855.7520.3.camel@compaq.olson.home","threadId":"24657","inReplyTo":"AANLkTi=G=GvxXEh1hGuYQK42cdkMUaFhqxsQ39K=2180@mail.gmail.com","subject":"Re: [PATCH v2] Allow HTTP user agent string to be modified.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-08-08T03:57:35Z","receivedAt":"2010-08-08T03:57:35Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"On Sun, 2010-08-08 at 10:51 +0800, Tay Ray Chuan wrote:\n\n> >  static char *user_name, *user_pass;\n> > +static const char *user_agent = NULL;\n> \n> This can be skipped, I think.\n\nMy only reason for wanting to initialize is because I don't trust all\ncompilers to follow the standard.  But, since there are so many other\ninstances of relying on the compiler to zero out static vars in other\nplaces already, I don't have any problem with conforming...\n\n\n> \n> >[snip]\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> Hmm, perhaps\n> \n>     curl_easy_setopt(result, CURLOPT_USERAGENT,\n>         user_agent ? user_agent : GIT_USER_AGENT);\n> \n> to replace the if-else?\n\nThat is perfectly fine with me.\n"},{"id":"147717","messageId":"1281504288-31836-1-git-send-email-olsonse@umich.edu","threadId":"24657","inReplyTo":"AANLkTi=G=GvxXEh1hGuYQK42cdkMUaFhqxsQ39K=2180@mail.gmail.com","subject":"[PATCH v3] Allow HTTP user agent string to be modified.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-08-11T05:24:48Z","receivedAt":"2010-08-11T05:24:48Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"Some firewalls restrict HTTP connections based on the clients user agent.  This\ncommit provides the user the ability to modify the user agent string via either\na new config option (http.useragent) or by an environment variable\n(GIT_USER_AGENT).  Relevant documentation is added to Documentation/config.txt.\n\nSigned-off-by: Spencer E. Olson <olsonse@umich.edu>\n---\n\nHi all,\n\nThis is an updated version of this patch including the changes suggested by Ray\nChuan.\n\n\n Documentation/config.txt |    9 +++++++++\n http.c                   |    9 ++++++++-\n 2 files changed, 17 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f81fb91..826e816 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,15 @@ http.noEPSV::\n \tsupport EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'\n \tenvironment variable. Default is false (curl will use EPSV).\n \n+http.useragent::\n+\tThe HTTP USER_AGENT string presented to an HTTP server.  The default\n+\tvalue represents the version of the client git such as git/1.7.1.\n+\tThis option allows you to override this value to a more common value\n+\tsuch as Mozilla/4.0.  This may be necessary, for instance, if\n+\tconnecting through a firewall that restricts HTTP connections to a set\n+\tof common USER_AGENT strings (but not including those like git/1.7.1).\n+\tCan be overridden by the 'GIT_USER_AGENT' environment variable.\n+\n i18n.commitEncoding::\n \tCharacter encoding the commit messages are stored in; git itself\n \tdoes not care per se, but this information is necessary e.g. when\ndiff --git a/http.c b/http.c\nindex 1320c50..b0b6925 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;\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 *value, void *cb)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(\"http.useragent\", var))\n+\t\treturn git_config_string(&user_agent, var, value);\n+\n \t/* Fall back on the default ones */\n \treturn git_default_config(var, value, cb);\n }\n@@ -279,7 +283,8 @@ static CURL *get_curl_handle(void)\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\tcurl_easy_setopt(result, CURLOPT_VERBOSE, 1);\n \n-\tcurl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n+\tcurl_easy_setopt(result, CURLOPT_USERAGENT,\n+\t\tuser_agent ? user_agent : GIT_USER_AGENT );\n \n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n@@ -380,6 +385,8 @@ void http_init(struct remote *remote)\n #endif\n \tset_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n \n+\tset_from_env(&user_agent, \"GIT_USER_AGENT\");\n+\n \tlow_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n \tif (low_speed_limit != NULL)\n \t\tcurl_low_speed_limit = strtol(low_speed_limit, NULL, 10);\n-- \n1.7.0.4\n"},{"id":"147727","messageId":"AANLkTim1=Sa++uabphu03gv4i+JakoOhxf1w91WLB4sd@mail.gmail.com","threadId":"24657","inReplyTo":"1281504288-31836-1-git-send-email-olsonse@umich.edu","subject":"Re: [PATCH v3] Allow HTTP user agent string to be modified.","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2010-08-11T08:04:02Z","receivedAt":"2010-08-11T08:04:02Z","isPatch":true,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"On Wed, Aug 11, 2010 at 1:24 PM, Spencer E. Olson <olsonse@umich.edu> wrote:\n> Some firewalls restrict HTTP connections based on the clients user agent.  This\n> commit provides the user the ability to modify the user agent string via either\n> a new config option (http.useragent) or by an environment variable\n> (GIT_USER_AGENT).  Relevant documentation is added to Documentation/config.txt.\n>\n> Signed-off-by: Spencer E. Olson <olsonse@umich.edu>\n> ---\n>\n> Hi all,\n>\n> This is an updated version of this patch including the changes suggested by Ray\n> Chuan.\n\n  Acked-by: Tay Ray Chuan <rctay89@gmail.com>\n\n-- \nCheers,\nRay Chuan\n"},{"id":"147827","messageId":"7v62zgyks6.fsf@alter.siamese.dyndns.org","threadId":"24657","inReplyTo":"1281504288-31836-1-git-send-email-olsonse@umich.edu","subject":"Re: [PATCH v3] Allow HTTP user agent string to be modified.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-11T20:08:41Z","receivedAt":"2010-08-11T20:08:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Spencer E. Olson\" <olsonse@umich.edu> writes:\n\n> diff --git a/http.c b/http.c\n> index 1320c50..b0b6925 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;\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 *value, void *cb)\n>  \t\treturn 0;\n>  \t}\n>  \n> +\tif (!strcmp(\"http.useragent\", var))\n> +\t\treturn git_config_string(&user_agent, var, value);\n> +\n>  \t/* Fall back on the default ones */\n>  \treturn git_default_config(var, value, cb);\n>  }\n> @@ -279,7 +283,8 @@ static CURL *get_curl_handle(void)\n>  \tif (getenv(\"GIT_CURL_VERBOSE\"))\n>  \t\tcurl_easy_setopt(result, CURLOPT_VERBOSE, 1);\n>  \n> -\tcurl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n> +\tcurl_easy_setopt(result, CURLOPT_USERAGENT,\n> +\t\tuser_agent ? user_agent : GIT_USER_AGENT );\n\nExcess space before \")\".\n\n>  \n>  \tif (curl_ftp_no_epsv)\n>  \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n> @@ -380,6 +385,8 @@ void http_init(struct remote *remote)\n>  #endif\n>  \tset_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n>  \n> +\tset_from_env(&user_agent, \"GIT_USER_AGENT\");\n\nThe name GIT_USER_AGENT may be Ok as an internal token used in our http\nimplementation, but the environment variable is an end-user facing entity.\n\nDon't we want to say HTTP somewhere, e.g. \"GIT_HTTP_USER_AGENT\"?\n\nIf \"User Agent\" means the \"browser claims to be...\" thing to everybody\nwithout much context then I won't worry too much, but MUA is a mail user\nagent, and we do use the term in our docs when describing send-email,\nso...\n"},{"id":"147830","messageId":"1281558725-29938-1-git-send-email-olsonse@umich.edu","threadId":"24657","inReplyTo":"7v62zgyks6.fsf@alter.siamese.dyndns.org","subject":"[PATCH v4] Allow HTTP user agent string to be modified.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-08-11T20:32:05Z","receivedAt":"2010-08-11T20:32:05Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"Some firewalls restrict HTTP connections based on the clients user agent.  This\ncommit provides the user the ability to modify the user agent string via either\na new config option (http.useragent) or by an environment variable\n(GIT_USER_AGENT).  Relevant documentation is added to Documentation/config.txt.\n\nSigned-off-by: Spencer E. Olson <olsonse@umich.edu>\n---\n\nAll,\n\nThis includes the changes suggested by Ray Chuan and by Junio Hamano, with one\nminor additional change:  This changes the internal -DGIT_USER_AGENT to\n-DGIT_HTTP_USER_AGENT.\n\nSince GIT_HTTP_* seems to follow what several of the other HTTP related\nenvironement variables, I agree that using GIT_HTTP_USER_AGENT is better for the\nuser interface (via env variables) than GIT_USER_AGENT.  I would like to\nadditionally change the internal token also to GIT_HTTP_USER_AGENT just because\nit is clearer for other developers.\n\n\n Documentation/config.txt |    9 +++++++++\n Makefile                 |    2 +-\n http.c                   |    9 ++++++++-\n 3 files changed, 18 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f81fb91..7253b71 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,15 @@ http.noEPSV::\n \tsupport EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'\n \tenvironment variable. Default is false (curl will use EPSV).\n \n+http.useragent::\n+\tThe HTTP USER_AGENT string presented to an HTTP server.  The default\n+\tvalue represents the version of the client git such as git/1.7.1.\n+\tThis option allows you to override this value to a more common value\n+\tsuch as Mozilla/4.0.  This may be necessary, for instance, if\n+\tconnecting through a firewall that restricts HTTP connections to a set\n+\tof common USER_AGENT strings (but not including those like git/1.7.1).\n+\tCan be overridden by the 'GIT_HTTP_USER_AGENT' environment variable.\n+\n i18n.commitEncoding::\n \tCharacter encoding the commit messages are stored in; git itself\n \tdoes not care per se, but this information is necessary e.g. when\ndiff --git a/Makefile b/Makefile\nindex e151516..f84f4a1 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1873,7 +1873,7 @@ builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \n config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n \n-http.s http.o: EXTRA_CPPFLAGS = -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"'\n+http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n \n ifdef NO_EXPAT\n http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\ndiff --git a/http.c b/http.c\nindex 1320c50..0a5011f 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;\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 *value, void *cb)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(\"http.useragent\", var))\n+\t\treturn git_config_string(&user_agent, var, value);\n+\n \t/* Fall back on the default ones */\n \treturn git_default_config(var, value, cb);\n }\n@@ -279,7 +283,8 @@ static CURL *get_curl_handle(void)\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\tcurl_easy_setopt(result, CURLOPT_VERBOSE, 1);\n \n-\tcurl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n+\tcurl_easy_setopt(result, CURLOPT_USERAGENT,\n+\t\tuser_agent ? user_agent : GIT_HTTP_USER_AGENT);\n \n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n@@ -380,6 +385,8 @@ void http_init(struct remote *remote)\n #endif\n \tset_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n \n+\tset_from_env(&user_agent, \"GIT_HTTP_USER_AGENT\");\n+\n \tlow_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n \tif (low_speed_limit != NULL)\n \t\tcurl_low_speed_limit = strtol(low_speed_limit, NULL, 10);\n-- \n1.7.0.4\n"},{"id":"147831","messageId":"AANLkTikzCVAb8YOZQhZ-sd6uhngiAQnhkB-k_JFZMem=@mail.gmail.com","threadId":"24657","inReplyTo":"1281558725-29938-1-git-send-email-olsonse@umich.edu","subject":"Re: [PATCH v4] Allow HTTP user agent string to be modified.","fromName":"Jacob Helwig","fromEmail":"jacob.helwig@gmail.com","sentAt":"2010-08-11T20:35:58Z","receivedAt":"2010-08-11T20:35:58Z","isPatch":true,"sender":{"key":"jacob.helwig@gmail.com","avatar":"https://avatars.githubusercontent.com/u/14557?v=4"},"body":"On Wed, Aug 11, 2010 at 13:32, Spencer E. Olson <olsonse@umich.edu> wrote:\n> Some firewalls restrict HTTP connections based on the clients user agent.  This\n> commit provides the user the ability to modify the user agent string via either\n> a new config option (http.useragent) or by an environment variable\n> (GIT_USER_AGENT).  Relevant documentation is added to Documentation/config.txt.\n>\n\nMissed switching GIT_USER_AGENT to GIT_HTTP_USER_AGENT here, in the\ncommit message, but that seems like something easily enough fixed when\napplying.\n\n> Signed-off-by: Spencer E. Olson <olsonse@umich.edu>\n> ---\n>\n> All,\n>\n> This includes the changes suggested by Ray Chuan and by Junio Hamano, with one\n> minor additional change:  This changes the internal -DGIT_USER_AGENT to\n> -DGIT_HTTP_USER_AGENT.\n>\n> Since GIT_HTTP_* seems to follow what several of the other HTTP related\n> environement variables, I agree that using GIT_HTTP_USER_AGENT is better for the\n> user interface (via env variables) than GIT_USER_AGENT.  I would like to\n> additionally change the internal token also to GIT_HTTP_USER_AGENT just because\n> it is clearer for other developers.\n>\n>\n>  Documentation/config.txt |    9 +++++++++\n>  Makefile                 |    2 +-\n>  http.c                   |    9 ++++++++-\n>  3 files changed, 18 insertions(+), 2 deletions(-)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index f81fb91..7253b71 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -1243,6 +1243,15 @@ http.noEPSV::\n>        support EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'\n>        environment variable. Default is false (curl will use EPSV).\n>\n> +http.useragent::\n> +       The HTTP USER_AGENT string presented to an HTTP server.  The default\n> +       value represents the version of the client git such as git/1.7.1.\n> +       This option allows you to override this value to a more common value\n> +       such as Mozilla/4.0.  This may be necessary, for instance, if\n> +       connecting through a firewall that restricts HTTP connections to a set\n> +       of common USER_AGENT strings (but not including those like git/1.7.1).\n> +       Can be overridden by the 'GIT_HTTP_USER_AGENT' environment variable.\n> +\n>  i18n.commitEncoding::\n>        Character encoding the commit messages are stored in; git itself\n>        does not care per se, but this information is necessary e.g. when\n> diff --git a/Makefile b/Makefile\n> index e151516..f84f4a1 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -1873,7 +1873,7 @@ builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n>\n>  config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n>\n> -http.s http.o: EXTRA_CPPFLAGS = -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"'\n> +http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n>\n>  ifdef NO_EXPAT\n>  http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\n> diff --git a/http.c b/http.c\n> index 1320c50..0a5011f 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;\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 *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,8 @@ 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> +       curl_easy_setopt(result, CURLOPT_USERAGENT,\n> +               user_agent ? user_agent : GIT_HTTP_USER_AGENT);\n>\n>        if (curl_ftp_no_epsv)\n>                curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n> @@ -380,6 +385,8 @@ void http_init(struct remote *remote)\n>  #endif\n>        set_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n>\n> +       set_from_env(&user_agent, \"GIT_HTTP_USER_AGENT\");\n> +\n>        low_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n>        if (low_speed_limit != NULL)\n>                curl_low_speed_limit = strtol(low_speed_limit, NULL, 10);\n> --\n> 1.7.0.4\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n"},{"id":"147832","messageId":"1281559238-30151-1-git-send-email-olsonse@umich.edu","threadId":"24657","inReplyTo":"AANLkTikzCVAb8YOZQhZ-sd6uhngiAQnhkB-k_JFZMem=@mail.gmail.com","subject":"[PATCH v5] Allow HTTP user agent string to be modified.","fromName":"Spencer E. Olson","fromEmail":"olsonse@umich.edu","sentAt":"2010-08-11T20:40:38Z","receivedAt":"2010-08-11T20:40:38Z","isPatch":true,"sender":{"key":"olsonse@umich.edu","avatar":"https://avatars.githubusercontent.com/u/148647?v=4"},"body":"Some firewalls restrict HTTP connections based on the clients user agent.  This\ncommit provides the user the ability to modify the user agent string via either\na new config option (http.useragent) or by an environment variable\n(GIT_HTTP_USER_AGENT).  Relevant documentation is added to\nDocumentation/config.txt.\n\nSigned-off-by: Spencer E. Olson <olsonse@umich.edu>\n---\n\nThanks Jacob.  Here is with the commit message fixed.\n\n\n Documentation/config.txt |    9 +++++++++\n Makefile                 |    2 +-\n http.c                   |    9 ++++++++-\n 3 files changed, 18 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex f81fb91..7253b71 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1243,6 +1243,15 @@ http.noEPSV::\n \tsupport EPSV mode. Can be overridden by the 'GIT_CURL_FTP_NO_EPSV'\n \tenvironment variable. Default is false (curl will use EPSV).\n \n+http.useragent::\n+\tThe HTTP USER_AGENT string presented to an HTTP server.  The default\n+\tvalue represents the version of the client git such as git/1.7.1.\n+\tThis option allows you to override this value to a more common value\n+\tsuch as Mozilla/4.0.  This may be necessary, for instance, if\n+\tconnecting through a firewall that restricts HTTP connections to a set\n+\tof common USER_AGENT strings (but not including those like git/1.7.1).\n+\tCan be overridden by the 'GIT_HTTP_USER_AGENT' environment variable.\n+\n i18n.commitEncoding::\n \tCharacter encoding the commit messages are stored in; git itself\n \tdoes not care per se, but this information is necessary e.g. when\ndiff --git a/Makefile b/Makefile\nindex e151516..f84f4a1 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1873,7 +1873,7 @@ builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \\\n \n config.s config.o: EXTRA_CPPFLAGS = -DETC_GITCONFIG='\"$(ETC_GITCONFIG_SQ)\"'\n \n-http.s http.o: EXTRA_CPPFLAGS = -DGIT_USER_AGENT='\"git/$(GIT_VERSION)\"'\n+http.s http.o: EXTRA_CPPFLAGS = -DGIT_HTTP_USER_AGENT='\"git/$(GIT_VERSION)\"'\n \n ifdef NO_EXPAT\n http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT\ndiff --git a/http.c b/http.c\nindex 1320c50..0a5011f 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;\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 *value, void *cb)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(\"http.useragent\", var))\n+\t\treturn git_config_string(&user_agent, var, value);\n+\n \t/* Fall back on the default ones */\n \treturn git_default_config(var, value, cb);\n }\n@@ -279,7 +283,8 @@ static CURL *get_curl_handle(void)\n \tif (getenv(\"GIT_CURL_VERBOSE\"))\n \t\tcurl_easy_setopt(result, CURLOPT_VERBOSE, 1);\n \n-\tcurl_easy_setopt(result, CURLOPT_USERAGENT, GIT_USER_AGENT);\n+\tcurl_easy_setopt(result, CURLOPT_USERAGENT,\n+\t\tuser_agent ? user_agent : GIT_HTTP_USER_AGENT);\n \n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n@@ -380,6 +385,8 @@ void http_init(struct remote *remote)\n #endif\n \tset_from_env(&ssl_cainfo, \"GIT_SSL_CAINFO\");\n \n+\tset_from_env(&user_agent, \"GIT_HTTP_USER_AGENT\");\n+\n \tlow_speed_limit = getenv(\"GIT_HTTP_LOW_SPEED_LIMIT\");\n \tif (low_speed_limit != NULL)\n \t\tcurl_low_speed_limit = strtol(low_speed_limit, NULL, 10);\n-- \n1.7.0.4\n"},{"id":"147921","messageId":"7v62zfu4na.fsf@alter.siamese.dyndns.org","threadId":"24657","inReplyTo":"1281559238-30151-1-git-send-email-olsonse@umich.edu","subject":"Re: [PATCH v5] Allow HTTP user agent string to be modified.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-12T17:23:05Z","receivedAt":"2010-08-12T17:23:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Looks good; thanks.\n"}]}