{"thread":{"id":"20069","subject":"[JGIT PATCH] Allow http_proxy values without protocol-part","startedAt":"2009-07-09T21:28:22Z","lastAt":"2009-07-10T15:22:09Z","messageCount":2,"participants":["Christian Halstrick","Shawn O. Pearce"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"117728","messageId":"20090709232822.00000164@unknown","threadId":"20069","inReplyTo":null,"subject":"[JGIT PATCH] Allow http_proxy values without protocol-part","fromName":"Christian Halstrick","fromEmail":"christian.halstrick@gmail.com","sentAt":"2009-07-09T21:28:22Z","receivedAt":"2009-07-09T21:28:22Z","isPatch":true,"sender":{"key":"christian.halstrick@gmail.com","avatar":"https://gravatar.com/avatar/3598bf518644c7dc32d4dcd8e0554b6a313e12103011862402c83ae2854203ce?d=mp&s=160"},"body":"From: Christian Halstrick <christian.halstrick@sap.com>\n\njgit reads the environment variable http_proxy to configure the proxy\nfor http traffic in the same way as applications using the libcurl\nlibrary. It would be nice if jgit would understand the same values as\nlibcurl, but for libcurl the protocol part is optional (e.g.\nhttp_proxy=proxy:8080 is valid). I changed jgit to also support\nhttp_proxy values without a protocol spec. When no protocol is\nspecified \"http://\" is assumed.\n\nSigned-off-by: Christian Halstrick <christian.halstrick@sap.com>\n---\n .../src/org/spearce/jgit/util/HttpSupport.java     |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java\nindex 33dfcee..5f21677 100644\n--- a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java\n+++ b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java\n@@ -69,7 +69,7 @@ public static void configureHttpProxy() throws MalformedURLException {\n \t\tif (s == null || s.equals(\"\"))\n \t\t\treturn;\n \n-\t\tfinal URL u = new URL(s);\n+\t\tfinal URL u = new URL((s.indexOf(\"://\")==-1) ? \"http://\"+s : s);\n \t\tif (!\"http\".equals(u.getProtocol()))\n \t\t\tthrow new MalformedURLException(\"Invalid http_proxy: \" + s\n \t\t\t\t\t+ \": Only http supported.\");\n-- \n1.6.3.2.1299.gee46c\n"},{"id":"117772","messageId":"20090710152209.GE11191@spearce.org","threadId":"20069","inReplyTo":"20090709232822.00000164@unknown","subject":"Re: [JGIT PATCH] Allow http_proxy values without protocol-part","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-07-10T15:22:09Z","receivedAt":"2009-07-10T15:22:09Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Sorry I didn't respond earlier this week, I was more or less offline\nfor basically 2.5 days.\n\nChristian Halstrick <christian.halstrick@gmail.com> wrote:\n> jgit reads the environment variable http_proxy to configure the proxy\n> for http traffic in the same way as applications using the libcurl\n> library. It would be nice if jgit would understand the same values as\n> libcurl, but for libcurl the protocol part is optional (e.g.\n> http_proxy=proxy:8080 is valid). I changed jgit to also support\n> http_proxy values without a protocol spec. When no protocol is\n> specified \"http://\" is assumed.\n\nThis didn't really fit with our style of commit messages.  Instead of\nsaying what you did, we prefer to say *why* you did it.  The what\nis clear from the diff.  The why is usually less clear.\n\nI replaced the message with the following:\n\n--8<--\nAllow http_proxy values without protocol-part\n\njgit reads the environment variable http_proxy to configure the\nJRE's URL library for HTTP traffic through the proxy in the same\nway as other applications that are using the libcurl library.\nlibcurl assumes \"http://\" when the protocol is not specified in\nhttp_proxy, so jgit should do the same.\n\nThus http_proxy=proxy:8080 is now valid.\n\nSigned-off-by: Christian Halstrick <christian.halstrick@sap.com>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n-->8--\n\n> diff --git a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java\n> index 33dfcee..5f21677 100644\n> --- a/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java\n> +++ b/org.spearce.jgit/src/org/spearce/jgit/util/HttpSupport.java\n> @@ -69,7 +69,7 @@ public static void configureHttpProxy() throws MalformedURLException {\n>  \t\tif (s == null || s.equals(\"\"))\n>  \t\t\treturn;\n>  \n> -\t\tfinal URL u = new URL(s);\n> +\t\tfinal URL u = new URL((s.indexOf(\"://\")==-1) ? \"http://\"+s : s);\n\nAlso, our formatting rules tend to place spaces around operators,\nso this line was reformatted slightly to honor that convention.\nIf you are using Eclipse, the projects should be configured\nautomatically with our preferred code formatting rules, though\nEclipse often gets Javadoc blocks wrong and adds a trailing space\non the end of a blank line.\n\nBut, patches applied clean, so your techique of sending works.\nThanks.\n\n-- \nShawn.\n"}]}