commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestURI.java
Date Wed, 11 Feb 2004 23:20:17 GMT
olegk       2004/02/11 15:20:17

  Modified:    httpclient/src/java/org/apache/commons/httpclient Tag:
                        HTTPCLIENT_2_0_BRANCH HttpURL.java
               httpclient/src/test/org/apache/commons/httpclient Tag:
                        HTTPCLIENT_2_0_BRANCH 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
  No                   revision
  No                   revision
  1.12.2.2  +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.12.2.1
  retrieving revision 1.12.2.2
  diff -u -r1.12.2.1 -r1.12.2.2
  --- HttpURL.java	29 Jan 2004 18:33:32 -0000	1.12.2.1
  +++ HttpURL.java	11 Feb 2004 23:20:17 -0000	1.12.2.2
  @@ -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();
  
  
  
  No                   revision
  No                   revision
  1.4.2.3   +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.4.2.2
  retrieving revision 1.4.2.3
  diff -u -r1.4.2.2 -r1.4.2.3
  --- TestURI.java	29 Jan 2004 18:33:32 -0000	1.4.2.2
  +++ TestURI.java	11 Feb 2004 23:20:17 -0000	1.4.2.3
  @@ -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());
  +    }
  +
   }
  
  
  

---------------------------------------------------------------------
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