Index: /home/gojomo/workspace/Commons-HttpClient 3.x TRUNK/src/java/org/apache/commons/httpclient/URI.java
===================================================================
--- /home/gojomo/workspace/Commons-HttpClient 3.x TRUNK/src/java/org/apache/commons/httpclient/URI.java	(revision 414947)
+++ /home/gojomo/workspace/Commons-HttpClient 3.x TRUNK/src/java/org/apache/commons/httpclient/URI.java	(working copy)
@@ -1914,7 +1914,8 @@
         boolean isStartedFromPath = false;
         int atColon = tmp.indexOf(':');
         int atSlash = tmp.indexOf('/');
-        if (atColon <= 0 || (atSlash >= 0 && atSlash < atColon)) {
+        if ((atColon <= 0 && !tmp.startsWith("//"))
+            || (atSlash >= 0 && atSlash < atColon)) {
             isStartedFromPath = true;
         }
 
@@ -1960,7 +1961,8 @@
         if (0 <= at && at < length && tmp.charAt(at) == '/') {
             // Set flag
             _is_hier_part = true;
-            if (at + 2 < length && tmp.charAt(at + 1) == '/') {
+            if (at + 2 < length && tmp.charAt(at + 1) == '/' 
+                && !isStartedFromPath) {
                 // the temporary index to start the search from
                 int next = indexFirstOf(tmp, "/?#", at + 2);
                 if (next == -1) {
Index: /home/gojomo/workspace/Commons-HttpClient 3.x TRUNK/src/test/org/apache/commons/httpclient/TestURI.java
===================================================================
--- /home/gojomo/workspace/Commons-HttpClient 3.x TRUNK/src/test/org/apache/commons/httpclient/TestURI.java	(revision 414947)
+++ /home/gojomo/workspace/Commons-HttpClient 3.x TRUNK/src/test/org/apache/commons/httpclient/TestURI.java	(working copy)
@@ -278,4 +278,15 @@
         }
     }    
     
+    /**
+     * Verify proper handling of relative URIs with embedded double-slashes,
+     * like "foo//bar//baz". 
+     * See bug http://issues.apache.org/jira/browse/HTTPCLIENT-588
+     * 
+     * @throws Exception
+     */
+    public void testRelativeWithDoubleSlash() throws Exception {
+        URI rel = new URI("foo//bar//baz",true);
+        assertEquals("foo//bar//baz",rel.toString());
+    }
 }
