Index: java/org/apache/commons/httpclient/HttpURL.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpURL.java,v retrieving revision 1.12.2.1 diff -u -r1.12.2.1 HttpURL.java --- java/org/apache/commons/httpclient/HttpURL.java 29 Jan 2004 18:33:32 -0000 1.12.2.1 +++ java/org/apache/commons/httpclient/HttpURL.java 9 Feb 2004 16:34:37 -0000 @@ -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(); Index: test/org/apache/commons/httpclient/TestURI.java =================================================================== RCS file: /home/cvspublic/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestURI.java,v retrieving revision 1.4.2.2 diff -u -r1.4.2.2 TestURI.java --- test/org/apache/commons/httpclient/TestURI.java 29 Jan 2004 18:33:32 -0000 1.4.2.2 +++ test/org/apache/commons/httpclient/TestURI.java 9 Feb 2004 16:34:38 -0000 @@ -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:password@localhost", 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:password@localhost:8080", url.getAuthority()); + } + }