From: Jeff King <peff@peff.net>
To: Nelson Benitez Leon <nelsonjesus.benitez@seap.minhap.es>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 1/6] http: try http_proxy env var when http.proxy config option is not set
Date: Fri, 4 May 2012 03:08:02 -0400 [thread overview]
Message-ID: <20120504070802.GA21895@sigill.intra.peff.net> (raw)
In-Reply-To: <4FA2B4D3.90809@seap.minhap.es>
On Thu, May 03, 2012 at 06:39:47PM +0200, Nelson Benitez Leon wrote:
> +static const char *read_prot_proxy_env(const char *protocol)
> +{
> + const char *env_proxy;
> + struct strbuf var = STRBUF_INIT;
> +
> + strbuf_addf(&var, "%s_proxy", protocol);
> + env_proxy = getenv(var.buf);
> + if (!env_proxy && strcmp("http_proxy", var.buf)) {
> + char *p;
> + for (p = var.buf; *p; p++)
> + *p = toupper(*p);
> + env_proxy = getenv(var.buf);
> + }
> + strbuf_release(&var);
> +
> + return env_proxy;
> +}
Thanks, this is way more readable than the previous iteration.
> +static int host_allowed_by_noproxy_env (const char *host)
> +{
> + const char *no_proxy = getenv("no_proxy");
> + if (!no_proxy)
> + no_proxy = getenv("NO_PROXY");
> + if (!no_proxy ||
> + (strcmp("*", no_proxy) &&
> + !strstr(no_proxy, host)))
> + return 1;
> +
> + return 0;
> +}
This simplified parsing misses a lot of corner cases. Three I can see
right off the bat:
1. If your NO_PROXY is "no-proxy.com", and your host is
"proxy.com", your code will consider that a match, but curl does
not.
2. If your NO_PROXY contains "no-proxy.com", but your host is
"www.no-proxy.com", curl will consider that a match, but your code
does not.
3. If your NO_PROXY contains "no-proxy.com", but your host is
"no-proxy.com:80", curl will consider that a match, but your code
does not.
I don't see any way around it besides implementing curl's full
tokenizing and matching algorithm, which is about a page of code. I'd
really prefer not to re-implement bits of curl (especially because they
may change later), but AFAIK there is no way to ask curl "is there a
proxy configured, and if so, what is it?".
The rest of this patch looks OK to me, though.
-Peff
next prev parent reply other threads:[~2012-05-04 7:08 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 16:39 [PATCH 1/6] http: try http_proxy env var when http.proxy config option is not set Nelson Benitez Leon
2012-05-03 18:05 ` Junio C Hamano
2012-05-04 7:08 ` Jeff King [this message]
2012-05-04 7:27 ` Daniel Stenberg
2012-05-04 7:39 ` Jeff King
2012-05-04 15:12 ` Daniel Stenberg
2012-05-04 15:36 ` Junio C Hamano
2012-05-04 16:05 ` Jeff King
2012-05-04 17:18 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120504070802.GA21895@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=nelsonjesus.benitez@seap.minhap.es \
/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).