olegk 2004/02/11 15:20:57 Modified: httpclient/src/java/org/apache/commons/httpclient HttpURL.java httpclient/src/test/org/apache/commons/httpclient TestURI.java Log: PR #26688 (HttpURL creates wrong authority String when user info is changed) Contributed by Oleg Kalnichevski Reviewed by Ortwin Glueck Revision Changes Path 1.14 +6 -6 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpURL.java Index: HttpURL.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpURL.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- HttpURL.java 29 Jan 2004 18:39:34 -0000 1.13 +++ HttpURL.java 11 Feb 2004 23:20:56 -0000 1.14 @@ -494,7 +494,7 @@ ? null : new String(escapedPassword); String userinfo = username + ((password == null) ? "" : ":" + password); String hostname = new String(getRawHost()); - String hostport = (_port == -1) ? hostname : hostname + _port; + String hostport = (_port == -1) ? hostname : hostname + ":" + _port; String authority = userinfo + "@" + hostport; _userinfo = userinfo.toCharArray(); _authority = authority.toCharArray(); @@ -556,7 +556,7 @@ String password = new String(getRawPassword()); String userinfo = username + ((password == null) ? "" : ":" + password); String hostname = new String(getRawHost()); - String hostport = (_port == -1) ? hostname : hostname + _port; + String hostport = (_port == -1) ? hostname : hostname + ":" + _port; String authority = userinfo + "@" + hostport; _userinfo = userinfo.toCharArray(); _authority = authority.toCharArray(); @@ -652,7 +652,7 @@ // an emtpy string is allowed as a password String userinfo = username + ((password == null) ? "" : ":" + password); String hostname = new String(getRawHost()); - String hostport = (_port == -1) ? hostname : hostname + _port; + String hostport = (_port == -1) ? hostname : hostname + ":" + _port; String authority = userinfo + "@" + hostport; _userinfo = userinfo.toCharArray(); _authority = authority.toCharArray(); 1.8 +18 -3 jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java Index: TestURI.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- TestURI.java 29 Jan 2004 18:39:34 -0000 1.7 +++ TestURI.java 11 Feb 2004 23:20:57 -0000 1.8 @@ -213,4 +213,19 @@ } + + public void testTestHttpUrlAuthorityString() throws Exception { + HttpURL url = new HttpURL("localhost", -1, "/"); + assertEquals("http://localhost/", url.toString()); + url.setRawUserinfo("user".toCharArray(), "password".toCharArray()); + assertEquals("http://localhost/", url.toString()); + assertEquals("user:[EMAIL PROTECTED]", url.getAuthority()); + + url = new HttpURL("localhost", 8080, "/"); + assertEquals("http://localhost:8080/", url.toString()); + url.setRawUserinfo("user".toCharArray(), "password".toCharArray()); + assertEquals("http://localhost:8080/", url.toString()); + assertEquals("user:[EMAIL PROTECTED]:8080", url.getAuthority()); + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]