threads / patch / 20069

patchAllow http_proxy values without protocol-part

Subject: [JGIT PATCH] Allow http_proxy values without protocol-part

## tl;dr

2 messages between Jul 9, 2009 and Jul 10, 2009. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Christian Halstrick· Jul 9, 2009, 21:28 UTC · lore
From: Christian Halstrick <christian.halstrick@sap.com>

jgit reads the environment variable http_proxy to configure the proxy for http traffic in the same way as applications using the libcurl library. It would be nice if jgit would understand the same values as libcurl, but for libcurl the protocol part is optional (e.g. http_proxy=proxy:8080 is valid). I changed jgit to also support http_proxy values without a protocol spec. When no protocol is specified "http://" is assumed.

Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
---
 .../src/org/spearce/jgit/util/HttpSupport.java     |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java +1 −1
diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java
index 33dfcee..5f21677 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java
@@ -69,7 +69,7 @@ public static void configureHttpProxy() throws MalformedURLException {
 		if (s == null || s.equals(""))
 			return;
 
-		final URL u = new URL(s);
+		final URL u = new URL((s.indexOf("://")==-1) ? "http://"+s : s);
 		if (!"http".equals(u.getProtocol()))
 			throw new MalformedURLException("Invalid http_proxy: " + s
 					+ ": Only http supported.");
-- 
1.6.3.2.1299.gee46c
Shawn O. Pearce· Jul 10, 2009, 15:22 UTC · re: Christian Halstrick · lore

Re: [JGIT PATCH] Allow http_proxy values without protocol-part

Sorry I didn't respond earlier this week, I was more or less offline for basically 2.5 days.

Christian Halstrick <christian.halstrick@gmail.com> wrote:
Show 7 quoted lines
> jgit reads the environment variable http_proxy to configure the proxy
> for http traffic in the same way as applications using the libcurl
> library. It would be nice if jgit would understand the same values as
> libcurl, but for libcurl the protocol part is optional (e.g.
> http_proxy=proxy:8080 is valid). I changed jgit to also support
> http_proxy values without a protocol spec. When no protocol is
> specified "http://" is assumed.

This didn't really fit with our style of commit messages. Instead of saying what you did, we prefer to say *why* you did it. The what is clear from the diff. The why is usually less clear.

I replaced the message with the following:

--8<-- Allow http_proxy values without protocol-part

jgit reads the environment variable http_proxy to configure the JRE's URL library for HTTP traffic through the proxy in the same way as other applications that are using the libcurl library. libcurl assumes "http://" when the protocol is not specified in http_proxy, so jgit should do the same.

Thus http_proxy=proxy:8080 is now valid.
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-->8--
Show 10 quoted lines
> diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java
> index 33dfcee..5f21677 100644
> --- a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java
> +++ b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java
> @@ -69,7 +69,7 @@ public static void configureHttpProxy() throws MalformedURLException {
>  		if (s == null || s.equals(""))
>  			return;
>  
> -		final URL u = new URL(s);
> +		final URL u = new URL((s.indexOf("://")==-1) ? "http://"+s : s);

Also, our formatting rules tend to place spaces around operators, so this line was reformatted slightly to honor that convention. If you are using Eclipse, the projects should be configured automatically with our preferred code formatting rules, though Eclipse often gets Javadoc blocks wrong and adds a trailing space on the end of a blank line.

But, patches applied clean, so your techique of sending works. Thanks.

-- 
Shawn.

← back to recent threads