commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r358634 - in /jakarta/commons/proper/httpclient/trunk/src: java/org/apache/commons/httpclient/HttpURL.java java/org/apache/commons/httpclient/URI.java test/org/apache/commons/httpclient/TestURI.java
Date Thu, 22 Dec 2005 21:23:26 GMT
Author: olegk
Date: Thu Dec 22 13:23:15 2005
New Revision: 358634

URL: http://svn.apache.org/viewcvs?rev=358634&view=rev
Log:
PR #37988 (UserInfo disapears after creating URI)

Contributed by Oleg Kalnichevski
Reviewed by Ortwin Gl├╝ck

Modified:
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpURL.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
    jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpURL.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpURL.java?rev=358634&r1=358633&r2=358634&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpURL.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpURL.java
Thu Dec 22 13:23:15 2005
@@ -828,5 +828,51 @@
         }
     }
 
+    /**
+     * Once it's parsed successfully, set this URI.
+     *
+     * @see #getRawURI
+     */
+    protected void setURI() {
+        // set _uri
+        StringBuffer buf = new StringBuffer();
+        // ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
+        if (_scheme != null) {
+            buf.append(_scheme);
+            buf.append(':');
+        }
+        if (_is_net_path) {
+            buf.append("//");
+            if (_authority != null) { // has_authority
+                if (_userinfo != null) { // by default, remove userinfo part
+                    if (_host != null) {
+                        buf.append(_host);
+                        if (_port != -1) {
+                            buf.append(':');
+                            buf.append(_port);
+                        }
+                    }
+                } else {
+                    buf.append(_authority);
+                }
+            }
+        }
+        if (_opaque != null && _is_opaque_part) {
+            buf.append(_opaque);
+        } else if (_path != null) {
+            // _is_hier_part or _is_relativeURI
+            if (_path.length != 0) {
+                buf.append(_path);
+            }
+        }
+        if (_query != null) { // has_query
+            buf.append('?');
+            buf.append(_query);
+        }
+        // ignore the fragment identifier
+        _uri = buf.toString().toCharArray();
+        hash = 0;
+    }
+    
 }
 

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java?rev=358634&r1=358633&r2=358634&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/URI.java
Thu Dec 22 13:23:15 2005
@@ -2263,17 +2263,7 @@
         if (_is_net_path) {
             buf.append("//");
             if (_authority != null) { // has_authority
-                if (_userinfo != null) { // by default, remove userinfo part
-                    if (_host != null) {
-                        buf.append(_host);
-                        if (_port != -1) {
-                            buf.append(':');
-                            buf.append(_port);
-                        }
-                    }
-                } else {
-                    buf.append(_authority);
-                }
+                buf.append(_authority);
             }
         }
         if (_opaque != null && _is_opaque_part) {

Modified: jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java?rev=358634&r1=358633&r2=358634&view=diff
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/test/org/apache/commons/httpclient/TestURI.java
Thu Dec 22 13:23:15 2005
@@ -181,6 +181,12 @@
         
     }
 
+    public void testTestURIAuthorityString() throws Exception {
+        URI url = new URI("ftp", "user:password", "localhost", -1, "/");
+        assertEquals("ftp://user:password@localhost/", url.toString());
+        assertEquals("user:password@localhost", url.getAuthority());
+    }
+    
     public void testTestHttpUrlAuthorityString() throws Exception {
         HttpURL url = new HttpURL("localhost", -1, "/");
         assertEquals("http://localhost/", url.toString());



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message